From: Aldy Hernandez Date: Mon, 12 Oct 2020 14:41:21 +0000 (-0400) Subject: operator_trunc_mod::wi_fold: Return VARYING for mod by zero. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=82118acc18e416b9c82c82ce7737f5e6246d6574;p=gcc.git 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 --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; +} +}