From 5b80069c7e65a3ed60ee16deac4a450a9c32efa6 Mon Sep 17 00:00:00 2001 From: Aldy Hernandez Date: Mon, 19 Oct 2020 09:48:27 +0200 Subject: Handle right shifts by zero in range-ops. 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. --- gcc/range-op.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/range-op.cc') diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 0efa001..30d2a4d 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -1579,6 +1579,11 @@ operator_lshift::op1_range (irange &r, 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; -- cgit v1.1