diff options
author | Jakub Jelinek <jakub@redhat.com> | 2016-03-15 17:11:48 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2016-03-15 17:11:48 +0100 |
commit | c39858bdb8b7abe0ef235039c69c429e666d5e63 (patch) | |
tree | 780aea325a716ecc198a88cd3bc011cf8ea2e921 /gcc/combine.c | |
parent | 511e5c4889a3d6fc41547031a8c1d8ac7915508a (diff) | |
download | gcc-c39858bdb8b7abe0ef235039c69c429e666d5e63.zip gcc-c39858bdb8b7abe0ef235039c69c429e666d5e63.tar.gz gcc-c39858bdb8b7abe0ef235039c69c429e666d5e63.tar.bz2 |
re PR rtl-optimization/70222 (Test miscompiled with -O1)
PR rtl-optimization/70222
* combine.c (simplify_shift_const_1): For A >> B >> C LSHIFTRT
optimization if mode is different from result_mode, queue up masking
of the result in outer_op. Formatting fix.
* gcc.c-torture/execute/pr70222-1.c: New test.
* gcc.c-torture/execute/pr70222-2.c: New test.
From-SVN: r234222
Diffstat (limited to 'gcc/combine.c')
-rw-r--r-- | gcc/combine.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/gcc/combine.c b/gcc/combine.c index 24dcefa..f701f28 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -10524,9 +10524,19 @@ simplify_shift_const_1 (enum rtx_code code, machine_mode result_mode, && CONST_INT_P (XEXP (varop, 0)) && !CONST_INT_P (XEXP (varop, 1))) { + /* For ((unsigned) (cstULL >> count)) >> cst2 we have to make + sure the result will be masked. See PR70222. */ + if (code == LSHIFTRT + && mode != result_mode + && !merge_outer_ops (&outer_op, &outer_const, AND, + GET_MODE_MASK (result_mode) + >> orig_count, result_mode, + &complement_p)) + break; + rtx new_rtx = simplify_const_binary_operation (code, mode, - XEXP (varop, 0), - GEN_INT (count)); + XEXP (varop, 0), + GEN_INT (count)); varop = gen_rtx_fmt_ee (code, mode, new_rtx, XEXP (varop, 1)); count = 0; continue; |