aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2020-10-16 15:02:42 -0400
committerAndrew MacLeod <amacleod@redhat.com>2020-10-16 15:05:11 -0400
commit4a135bd987e7bff6d3b94efa085e0c246348b486 (patch)
tree2b9ce23bed5a4a1e81d411e70ffa119a934f2e7c /gcc
parentccb4f20cbee1756c464033bbdda2f27b6aa2a63f (diff)
downloadgcc-4a135bd987e7bff6d3b94efa085e0c246348b486.zip
gcc-4a135bd987e7bff6d3b94efa085e0c246348b486.tar.gz
gcc-4a135bd987e7bff6d3b94efa085e0c246348b486.tar.bz2
Don't assert on a negative shift.
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/range-op.cc3
-rw-r--r--gcc/testsuite/gcc.dg/pr97462.c10
2 files changed, 12 insertions, 1 deletions
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index 6108de3..de4cfe4 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -1577,7 +1577,8 @@ operator_lshift::op1_range (irange &r,
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;
diff --git a/gcc/testsuite/gcc.dg/pr97462.c b/gcc/testsuite/gcc.dg/pr97462.c
new file mode 100644
index 0000000..52c0533
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr97462.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -w" } */
+
+int a, b;
+
+void d ()
+{
+ a << ~0 && b;
+ b = a;
+}