Don't assert, simply Return false for negative shifts as we can't tell
anything about the operand.
PR tree-optimization/97462
gcc/
* range-op.cc (operator_lshift::op1_range): Don't trap on negative
shifts.
gcc/testsuite/
* gcc.dg/pr97462.c: New file.
if (op2.singleton_p (&shift_amount))
{
wide_int shift = wi::to_wide (shift_amount);
- gcc_checking_assert (wi::gt_p (shift, 0, SIGNED));
+ if (wi::lt_p (shift, 0, SIGNED))
+ return false;
// Work completely in unsigned mode to start.
tree utype = type;
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -w" } */
+
+int a, b;
+
+void d ()
+{
+ a << ~0 && b;
+ b = a;
+}