]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
middle-end/103248 - fix RDIV_EXPR handling with fixed point
authorRichard Biener <rguenther@suse.de>
Tue, 16 Nov 2021 10:47:26 +0000 (11:47 +0100)
committerRichard Biener <rguenther@suse.de>
Fri, 19 Nov 2021 08:35:57 +0000 (09:35 +0100)
This fixes the previous adjustment to operation_could_trap_helper_p
where I failed to realize that RDIV_EXPR is also used for
fixed-point types.  It also fixes that handling by properly
checking for a fixed_zerop divisor.

2021-11-16  Richard Biener  <rguenther@suse.de>

PR middle-end/103248
* tree-eh.c (operation_could_trap_helper_p): Properly handle
fixed-point RDIV_EXPR.

* gcc.dg/pr103248.c: New testcase.

gcc/testsuite/gcc.dg/pr103248.c [new file with mode: 0644]
gcc/tree-eh.c

diff --git a/gcc/testsuite/gcc.dg/pr103248.c b/gcc/testsuite/gcc.dg/pr103248.c
new file mode 100644 (file)
index 0000000..da6232d
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target fixed_point } */
+/* { dg-options "-fnon-call-exceptions" } */
+
+_Accum sa;
+int c;
+
+void div_csa() { c /= sa; }
index 3eff07fc8feb23d215e2e9aa1d7d274aef309db3..916da85af2ef0ceb08736d3a7264d1f2ffbcba26 100644 (file)
@@ -2474,10 +2474,16 @@ operation_could_trap_helper_p (enum tree_code op,
       return false;
 
     case RDIV_EXPR:
-      if (honor_snans)
+      if (fp_operation)
+       {
+         if (honor_snans)
+           return true;
+         return flag_trapping_math;
+       }
+      /* Fixed point operations also use RDIV_EXPR.  */
+      if (!TREE_CONSTANT (divisor) || fixed_zerop (divisor))
        return true;
-      gcc_assert (fp_operation);
-      return flag_trapping_math;
+      return false;
 
     case LT_EXPR:
     case LE_EXPR: