Special case shifting by zero in operator_rshift::op1_range.
authorAldy Hernandez <aldyh@redhat.com>
Tue, 20 Oct 2020 06:53:21 +0000 (08:53 +0200)
committerAldy Hernandez <aldyh@redhat.com>
Tue, 20 Oct 2020 08:33:48 +0000 (10:33 +0200)
gcc/ChangeLog:

* range-op.cc (operator_rshift::op1_range): Special case
shifting by zero.

gcc/range-op.cc

index 21d98de2240621ed2ef2a6a534981b3b67703335..ee62f103598aff16549f45a0949be350f98f1848 100644 (file)
@@ -1642,6 +1642,11 @@ operator_rshift::op1_range (irange &r,
                    wi::uhwi (prec, TYPE_PRECISION (TREE_TYPE (shift))),
                    UNSIGNED))
        return false;
+      if (wi::to_wide (shift) == 0)
+       {
+         r = lhs;
+         return true;
+       }
 
       // Folding the original operation may discard some impossible
       // ranges from the LHS.