@@ -2692,13 +2692,13 @@ operator_trunc_mod::op1_range (irange &r
if (TYPE_SIGN (type) == SIGNED && wi::ge_p (op2.lower_bound (), 0, SIGNED))
{
unsigned prec = TYPE_PRECISION (type);
- // if a & b >=0 , then a >= 0.
- if (wi::ge_p (lhs.lower_bound (), 0, SIGNED))
+ // if a % b > 0 , then a >= 0.
+ if (wi::gt_p (lhs.lower_bound (), 0, SIGNED))
{
r = value_range (type, wi::zero (prec), wi::max_value (prec, SIGNED));
return true;
}
- // if a & b < 0 , then a <= 0.
+ // if a % b < 0 , then a <= 0.
if (wi::lt_p (lhs.upper_bound (), 0, SIGNED))
{
r = value_range (type, wi::min_value (prec, SIGNED), wi::zero (prec));
@@ -1,3 +1,4 @@
+/* PR tree-optimization/91029 */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-evrp" } */
@@ -16,7 +17,7 @@ void f1 (int i)
void f2 (int i)
{
- if ((i % 7) >= 0)
+ if ((i % 7) > 0)
{
xx = (i < 0);
if (xx)
@@ -0,0 +1,24 @@
+/* PR tree-optimization/97888 */
+
+int a = 1, c = 4, d, e;
+
+int
+main ()
+{
+ int f = -173;
+ int b;
+ for (b = 0; b < 10; b++)
+ {
+ int g = f % (~0 && a), h = 0, i = 0;
+ if (g)
+ __builtin_unreachable ();
+ if (c)
+ h = f;
+ if (h > -173)
+ e = d / i;
+ f = h;
+ }
+ if (f != -173)
+ __builtin_abort ();
+ return 0;
+}
@@ -0,0 +1,19 @@
+/* PR tree-optimization/97888 */
+
+__attribute__((noipa)) void
+foo (int i)
+{
+ if ((i % 7) >= 0)
+ {
+ if (i >= 0)
+ __builtin_abort ();
+ }
+}
+
+int
+main ()
+{
+ foo (-7);
+ foo (-21);
+ return 0;
+}