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.
// 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;
}
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;
}
--- /dev/null
+// { 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;
+}
+}