diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2021-10-02 16:59:26 +0200 |
---|---|---|
committer | Aldy Hernandez <aldyh@redhat.com> | 2021-10-02 21:50:45 +0200 |
commit | 6c0dd02964a624c65859808f9a40721c3796319a (patch) | |
tree | 57fc11db3490e81c99275ad5aecadfd7634be565 /gcc | |
parent | d7705b0ada9e9852b580ca25a45570c82152f287 (diff) | |
download | gcc-6c0dd02964a624c65859808f9a40721c3796319a.zip gcc-6c0dd02964a624c65859808f9a40721c3796319a.tar.gz gcc-6c0dd02964a624c65859808f9a40721c3796319a.tar.bz2 |
[PR102563] Do not clobber range in operator_lshift::op1_range.
We're clobbering the final range before we're done calculating it.
Tested on x86-64 Linux.
gcc/ChangeLog:
PR tree-optimization/102563
* range-op.cc (operator_lshift::op1_range): Do not clobber
range.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/pr102563.c: New test.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/range-op.cc | 12 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/pr102563.c | 16 |
2 files changed, 22 insertions, 6 deletions
diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 2baca4a..bbf2924 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -2112,8 +2112,6 @@ operator_lshift::op1_range (irange &r, else op_rshift.fold_range (tmp_range, utype, lhs, op2); - r.intersect (tmp_range); - // Start with ranges which can produce the LHS by right shifting the // result by the shift amount. // ie [0x08, 0xF0] = op1 << 2 will start with @@ -2128,13 +2126,15 @@ operator_lshift::op1_range (irange &r, unsigned low_bits = TYPE_PRECISION (utype) - TREE_INT_CST_LOW (shift_amount); wide_int up_mask = wi::mask (low_bits, true, TYPE_PRECISION (utype)); - wide_int new_ub = wi::bit_or (up_mask, r.upper_bound ()); - wide_int new_lb = wi::set_bit (r.lower_bound (), low_bits); + wide_int new_ub = wi::bit_or (up_mask, tmp_range.upper_bound ()); + wide_int new_lb = wi::set_bit (tmp_range.lower_bound (), low_bits); int_range<2> fill_range (utype, new_lb, new_ub); - r.union_ (fill_range); + tmp_range.union_ (fill_range); if (utype != type) - range_cast (r, type); + range_cast (tmp_range, type); + + r.intersect (tmp_range); return true; } diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr102563.c b/gcc/testsuite/gcc.dg/tree-ssa/pr102563.c new file mode 100644 index 0000000..8871dff --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr102563.c @@ -0,0 +1,16 @@ +// { dg-do compile } +// { dg-options "-O2 -w" } + +int _bdf_parse_glyphs_bp; +long _bdf_parse_glyphs_nibbles; + +void _bdf_parse_glyphs_p() +{ + long p_2; + + _bdf_parse_glyphs_nibbles = p_2 << 1; + + for (; 0 < _bdf_parse_glyphs_nibbles;) + if (1 < _bdf_parse_glyphs_nibbles) + _bdf_parse_glyphs_bp = _bdf_parse_glyphs_p; +} |