* [PATCH] Don't assert on a negative shift.
@ 2020-10-16 19:05 Andrew MacLeod
0 siblings, 0 replies; only message in thread
From: Andrew MacLeod @ 2020-10-16 19:05 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 227 bytes --]
We were asserting that the shifts should not be negative, instead, just
return false indicating we can't tell anything about operand1 from the
result.
Bootstrapped on x86_64-pc-linux-gnu, no regressions, pushed.
Andrew
[-- Attachment #2: pr97462.diff --]
[-- Type: text/x-patch, Size: 1010 bytes --]
2020-10-16 Andrew Macleod <amacl:xeod@redhat.com>
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.
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index 6108de367ad..0efa00186e8 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 00000000000..52c0533c98e
--- /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;
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-10-16 19:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-16 19:05 [PATCH] Don't assert on a negative shift Andrew MacLeod
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).