gcc/ChangeLog:
PR tree-optimization/97371
* range-op.cc (operator_rshift::op1_range): Ignore shifts larger than
or equal to type precision.
gcc/testsuite/ChangeLog:
* gcc.dg/pr97371.c: New test.
tree shift;
if (op2.singleton_p (&shift))
{
+ // Ignore nonsensical shifts.
+ unsigned prec = TYPE_PRECISION (type);
+ if (wi::ge_p (wi::to_wide (shift),
+ wi::uhwi (prec, TYPE_PRECISION (TREE_TYPE (shift))),
+ UNSIGNED))
+ return false;
+
// Folding the original operation may discard some impossible
// ranges from the LHS.
int_range_max lhs_refined;
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -w" } */
+
+int a, b;
+void c() {
+ if (b >> 38)
+ a = b;
+}