public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Remove can_throw_non_call_exceptions special case from operator_div::wi_fold.
@ 2021-11-29 14:00 Aldy Hernandez
  2021-11-29 14:39 ` Jeff Law
  0 siblings, 1 reply; 8+ messages in thread
From: Aldy Hernandez @ 2021-11-29 14:00 UTC (permalink / raw)
  To: Richard Biener; +Cc: GCC patches, Andrew MacLeod, Aldy Hernandez

As discussed in the PR.  The code makes no difference, so whatever test
we added this special case for has been fixed or is being papered over.
I think we should fix any fall out upstream.

[Unless Andrew can remember why we added this and it still applies.]

Tested on x86-64 Linux.

OK for trunk?

	PR 103451

gcc/ChangeLog:

	* range-op.cc (operator_div::wi_fold): Remove
	can_throw_non_call_exceptions special case.

gcc/testsuite/ChangeLog:

	* gcc.dg/pr103451.c: New test.
---
 gcc/range-op.cc                 |  7 -------
 gcc/testsuite/gcc.dg/pr103451.c | 17 +++++++++++++++++
 2 files changed, 17 insertions(+), 7 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/pr103451.c

diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index bbf2924f815..6fe5f1cb4e0 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -1832,13 +1832,6 @@ operator_div::wi_fold (irange &r, tree type,
       return;
     }
 
-  // If flag_non_call_exceptions, we must not eliminate a division by zero.
-  if (cfun->can_throw_non_call_exceptions)
-    {
-      r.set_varying (type);
-      return;
-    }
-
   // If we're definitely dividing by zero, there's nothing to do.
   if (wi_zero_p (type, divisor_min, divisor_max))
     {
diff --git a/gcc/testsuite/gcc.dg/pr103451.c b/gcc/testsuite/gcc.dg/pr103451.c
new file mode 100644
index 00000000000..b83646d0b83
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr103451.c
@@ -0,0 +1,17 @@
+// { dg-do compile }
+// { dg-options "-O2 -w" }
+
+int func_10_ptr_12;
+
+void func_10(long li_8) 
+{
+  long *ptr_9 = &li_8;
+  li_8 &= *ptr_9 / 0 ?: li_8;
+  for (;;)
+    func_10_ptr_12 &= 4 ? *ptr_9 : 4;
+}
+
+void func_9_s_8() 
+{ 
+  func_10(func_9_s_8); 
+}
-- 
2.31.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-11-30  9:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-29 14:00 [PATCH] Remove can_throw_non_call_exceptions special case from operator_div::wi_fold Aldy Hernandez
2021-11-29 14:39 ` Jeff Law
2021-11-29 14:48   ` Richard Biener
2021-11-29 15:24     ` Aldy Hernandez
2021-11-30  7:37       ` Richard Biener
2021-11-30  8:51         ` Aldy Hernandez
2021-11-30  9:00           ` Richard Biener
2021-11-30  9:04             ` Aldy Hernandez

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