Remove zero from IOR ranges with non-zero masks.
gcc/
PR tree-optimization/83072
* range-op.cc (wi_optimize_and_or): Remove zero from IOR range when
mask is non-zero.
gcc/testsuite/
* gcc.dg/pr83072.c: New.
else
gcc_unreachable ();
value_range_with_overflow (r, type, res_lb, res_ub);
+
+ // Furthermore, if the mask is non-zero, an IOR cannot contain zero.
+ if (code == BIT_IOR_EXPR && wi::ne_p (mask, 0))
+ {
+ int_range<2> tmp;
+ tmp.set_nonzero (type);
+ r.intersect (tmp);
+ }
return true;
}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-evrp -fno-tree-ccp -fno-tree-forwprop -fno-tree-fre" } */
+
+void kill (void);
+
+int f(int c){
+ c |= 1;
+ if (c == 0)
+ kill ();
+
+ return c;
+}
+
+/* { dg-final { scan-tree-dump-not "kill" "evrp" } } */