From: Lulu Cheng <chenglulu@loongson.cn>
To: Xi Ruoyao <xry111@xry111.site>
Cc: Richard Biener <richard.guenther@gmail.com>,
GCC Patches <gcc-patches@gcc.gnu.org>,
Chenghua Xu <xuchenghua@loongson.cn>,
Weining Lu <luweining@loongson.cn>, Wang Xuerui <i@xen0n.name>
Subject: Re: [PATCH] loongarch: use -mno-check-zero-division as the default for optimized code
Date: Sat, 2 Jul 2022 15:39:39 +0800 [thread overview]
Message-ID: <03929777-80a0-dcc1-3e04-9811583eebd3@loongson.cn> (raw)
In-Reply-To: <CAFiYyc2CEAwPfk0=0f4c+f380qiPuHy+DOeqh1zCtVh1Lp4ZoA@mail.gmail.com>
在 2022/6/30 下午2:55, Richard Biener 写道:
> On Thu, Jun 30, 2022 at 5:00 AM Xi Ruoyao via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
>> Hi,
>>
>> We've made a consensus [1] that not to enable trapping for division by
>> zero by default for LLVM, and we think GCC should behave similarly.
>>
>> The main rationales:
>>
>> 1. Division by zero is undefined behavior, so in theory any portable
>> program shall not depend on it.
>> 2. There are already many targets where both the hardware and GCC port
>> do nothing to trap on division by zero. A list taken from
>> gcc.c-torture/execute/20101011-1.c: PowerPC, RISC-V, ARM64, MSP430, and
>> many others. So in practice any portable program cannot depend on this
>> trap.
>> 3. As an ICPC assistant coach, I'm well aware that the main disadvantage
>> not to trap on division by zero is "it breaks expectations of newbies".
>> So, we keep -mcheck-zero-division defaulted for -O0 and -Og. For other
>> optimization levels, it's well known that UBs are already breaking
>> newbies' expectations [2].
>> 4. GCC is going to optimize more heavily exploiting integer division by
>> zero [3]. So let's stop encouraging people to rely on any integer
>> division by zero behavior from now.
>>
>> [1]: https://reviews.llvm.org/D128572/new/#3612039
>> [2]: http://blog.llvm.org/2011/05/what-every-c-programmer-should-know_14.html
>> [3]: https://gcc.gnu.org/pipermail/gcc-patches/2022-May/595099.html
>>
>> Patch content following. Bootstrapped and regtested on loongarch64-
>> linux-gnu. Ok for trunk?
> It might be worth backporting this behavioral change to the GCC 12 branch
> as well (so 12.1 is the only release with different default behavior) and
> documenting the change in changes.html
diff --git a/gcc/common/config/loongarch/loongarch-common.cc
b/gcc/common/config/loongarch/loongarch-common.cc
index b6cbd84b873..f8b4660fabf 100644
--- a/gcc/common/config/loongarch/loongarch-common.cc
+++ b/gcc/common/config/loongarch/loongarch-common.cc
@@ -38,7 +38,4 @@ static const struct default_options
loongarch_option_optimization_table[] =
{ OPT_LEVELS_NONE, 0, NULL, 0 }
};
-#undef TARGET_DEFAULT_TARGET_FLAGS
-#define TARGET_DEFAULT_TARGET_FLAGS MASK_CHECK_ZERO_DIV
-
I think this modifications are needed, and there is no problem with the
rest.
Thanks!
Lulu Cheng
next prev parent reply other threads:[~2022-07-02 7:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-30 2:59 Xi Ruoyao
2022-06-30 6:55 ` Richard Biener
2022-07-02 7:39 ` Lulu Cheng [this message]
2022-07-02 8:24 ` Xi Ruoyao
2022-07-02 8:35 ` Lulu Cheng
2022-07-03 3:06 ` Xi Ruoyao
2022-07-04 6:25 ` Lulu Cheng
2022-07-04 6:55 ` Xi Ruoyao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=03929777-80a0-dcc1-3e04-9811583eebd3@loongson.cn \
--to=chenglulu@loongson.cn \
--cc=gcc-patches@gcc.gnu.org \
--cc=i@xen0n.name \
--cc=luweining@loongson.cn \
--cc=richard.guenther@gmail.com \
--cc=xry111@xry111.site \
--cc=xuchenghua@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).