aboutsummaryrefslogtreecommitdiff
path: root/gcc/common
diff options
context:
space:
mode:
authorXi Ruoyao <xry111@xry111.site>2022-07-02 16:16:44 +0800
committerXi Ruoyao <xry111@xry111.site>2022-07-03 11:03:26 +0800
commitf150dc1bd11802b70277f0fa209f2d23695a1095 (patch)
tree9133d8fb81d95414f60ea7a3065c96e4d97bd7fd /gcc/common
parentb5c3dd3df381896b09fa76b52cd7a49b9b24afb3 (diff)
downloadgcc-f150dc1bd11802b70277f0fa209f2d23695a1095.zip
gcc-f150dc1bd11802b70277f0fa209f2d23695a1095.tar.gz
gcc-f150dc1bd11802b70277f0fa209f2d23695a1095.tar.bz2
loongarch: use -mno-check-zero-division as the default for optimized code
Integer division by zero is undefined behavior anyway, and there are already many platforms where neither the GCC port and the hardware do anything to trap on division by zero. So any portable program shall not rely on SIGFPE on division by zero, in both theory and practice. As the result, there is no real reason to cost two additional instructions just for the trap on division by zero with a new ISA. One remaining reason to trap on division by zero may be debugging, especially while -fsanitize=integer-divide-by-zero is not implemented for LoongArch yet. To make debugging easier, keep -mcheck-zero-division as the default for -O0 and -Og, but use -mno-check-zero-division as the default for all other optimization levels. Co-authored-by: Lulu Cheng <chenglulu@loongson.cn> gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_check_zero_div_p): New static function. (loongarch_idiv_insns): Use loongarch_check_zero_div_p instead of TARGET_CHECK_ZERO_DIV. (loongarch_output_division): Likewise. * common/config/loongarch/loongarch-common.cc (TARGET_DEFAULT_TARGET_FLAGS): Remove unneeded hook. * doc/invoke.texi: Update to match the new behavior. gcc/testsuite/ChangeLog: * gcc.c-torture/execute/20101011-1.c (dg-additional-options): add -mcheck-zero-division for LoongArch targets.
Diffstat (limited to 'gcc/common')
-rw-r--r--gcc/common/config/loongarch/loongarch-common.cc3
1 files changed, 0 insertions, 3 deletions
diff --git a/gcc/common/config/loongarch/loongarch-common.cc b/gcc/common/config/loongarch/loongarch-common.cc
index 085d3d9..ed3730f 100644
--- a/gcc/common/config/loongarch/loongarch-common.cc
+++ b/gcc/common/config/loongarch/loongarch-common.cc
@@ -37,7 +37,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
-
struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;