public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-3830] operator_trunc_mod::wi_fold: Return VARYING for mod by zero.
@ 2020-10-12 16:53 Aldy Hernandez
  0 siblings, 0 replies; only message in thread
From: Aldy Hernandez @ 2020-10-12 16:53 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:82118acc18e416b9c82c82ce7737f5e6246d6574

commit r11-3830-g82118acc18e416b9c82c82ce7737f5e6246d6574
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Mon Oct 12 10:41:21 2020 -0400

    operator_trunc_mod::wi_fold: Return VARYING for mod by zero.
    
    gcc/ChangeLog:
    
            PR tree-optimization/97378
            * range-op.cc (operator_trunc_mod::wi_fold): Return VARYING for mod by zero.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.dg/pr97378.c: New test.

Diff:
---
 gcc/range-op.cc                |  6 +++---
 gcc/testsuite/gcc.dg/pr97378.c | 15 +++++++++++++++
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index ce6ae2de20c..6108de367ad 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -1359,7 +1359,7 @@ operator_div::wi_fold (irange &r, tree type,
   // If we're definitely dividing by zero, there's nothing to do.
   if (wi_zero_p (type, divisor_min, divisor_max))
     {
-      r.set_undefined ();
+      r.set_varying (type);
       return;
     }
 
@@ -2624,10 +2624,10 @@ operator_trunc_mod::wi_fold (irange &r, tree type,
   signop sign = TYPE_SIGN (type);
   unsigned prec = TYPE_PRECISION (type);
 
-  // Mod 0 is undefined.  Return undefined.
+  // Mod 0 is undefined.
   if (wi_zero_p (type, rh_lb, rh_ub))
     {
-      r.set_undefined ();
+      r.set_varying (type);
       return;
     }
 
diff --git a/gcc/testsuite/gcc.dg/pr97378.c b/gcc/testsuite/gcc.dg/pr97378.c
new file mode 100644
index 00000000000..27e4a1f4321
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr97378.c
@@ -0,0 +1,15 @@
+// { dg-do compile }
+// { dg-options "-O2" }
+
+int a, b, c;
+void d() {
+e : {
+  long f;
+  long *g = &f;
+  if ((a != 0) - (b = 0))
+    ;
+  else
+    a &= (*g %= a *= c) >= (*g || f);
+  goto e;
+}
+}


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

only message in thread, other threads:[~2020-10-12 16:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-12 16:53 [gcc r11-3830] operator_trunc_mod::wi_fold: Return VARYING for mod by zero 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).