If the shift amount in operator_lshift::op1_range was zero, an invalid range
of [1, 0] was being created.
gcc/ChangeLog:
PR tree-optimization/97467
* range-op.cc (operator_lshift::op1_range): Handle shifts by 0.
gcc/testsuite/ChangeLog:
* gcc.dg/pr97467.c: New test.
wide_int shift = wi::to_wide (shift_amount);
if (wi::lt_p (shift, 0, SIGNED))
return false;
+ if (shift == 0)
+ {
+ r = lhs;
+ return true;
+ }
// Work completely in unsigned mode to start.
tree utype = type;
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-Os" } */
+
+int a;
+long b;
+unsigned int c = 1;
+
+int main () {
+ int e;
+ for (; c <= 0; c++) {
+ int f = 0;
+ b = e;
+ a = f || b << c;
+ }
+ return 0;
+}