diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2020-05-14 16:31:27 +0200 |
---|---|---|
committer | Aldy Hernandez <aldyh@redhat.com> | 2020-05-15 08:50:16 +0200 |
commit | a80468e8ee8834f20819023d684f73175eb63880 (patch) | |
tree | b166914943cce33484d00a4fcd962fa87548ff3b | |
parent | 304543d8ff80796ef7fa6afdf0ab6bffa5698c9a (diff) | |
download | gcc-a80468e8ee8834f20819023d684f73175eb63880.zip gcc-a80468e8ee8834f20819023d684f73175eb63880.tar.gz gcc-a80468e8ee8834f20819023d684f73175eb63880.tar.bz2 |
Return a better range for lshift::op1_range if LHS does not contain a 0.
-rw-r--r-- | gcc/range-op.cc | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 131f224..f4d4de5 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -1443,8 +1443,7 @@ operator_lshift::fold_range (irange &r, tree type, bool saved_flag_wrapv_pointer = flag_wrapv_pointer; flag_wrapv = 1; flag_wrapv_pointer = 1; - bool b = range_op_handler (MULT_EXPR, type)->fold_range (r, type, op1, - mult); + bool b = op_mult.fold_range (r, type, op1, mult); flag_wrapv = saved_flag_wrapv; flag_wrapv_pointer = saved_flag_wrapv_pointer; return b; @@ -1605,8 +1604,7 @@ operator_rshift::op1_range (irange &r, { widest_irange shift_range (shift, shift); widest_irange lb, ub; - range_op_handler (LSHIFT_EXPR, type)->fold_range (lb, type, lhs, - shift_range); + op_lshift.fold_range (lb, type, lhs, shift_range); // LHS // 0000 0111 = OP1 >> 3 // @@ -1619,10 +1617,16 @@ operator_rshift::op1_range (irange &r, build_minus_one_cst (type), shift)); widest_irange mask_range (build_zero_cst (type), mask); - range_op_handler (PLUS_EXPR, type)->fold_range (ub, type, lb, - mask_range); + op_plus.fold_range (ub, type, lb, mask_range); r = lb; r.union_ (ub); + + if (!lhs.contains_p (build_zero_cst (lhs.type ()))) + { + mask_range.invert (); + r.intersect (mask_range); + } + return true; } return false; |