public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] middle-end/103248 - fix RDIV_EXPR handling with fixed point
@ 2021-11-16 11:57 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2021-11-16 11:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: joseph

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.

Bootstrapped and tested on x86_64-unknown-linux-gnu, OK?

Thanks,
Richard.

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 |  8 ++++++++
 gcc/tree-eh.c                   | 12 +++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/pr103248.c

diff --git a/gcc/testsuite/gcc.dg/pr103248.c b/gcc/testsuite/gcc.dg/pr103248.c
new file mode 100644
index 00000000000..da6232d21ee
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr103248.c
@@ -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; }
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index 3eff07fc8fe..916da85af2e 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -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:
-- 
2.31.1

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-16 11:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-16 11:57 [PATCH] middle-end/103248 - fix RDIV_EXPR handling with fixed point Richard Biener

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).