aboutsummaryrefslogtreecommitdiff
path: root/gcc/combine.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2016-01-31 23:32:01 -0800
committerRichard Henderson <rth@gcc.gnu.org>2016-01-31 23:32:01 -0800
commite6c0c44b5b43c4fef77f3a566d035db5c589ff99 (patch)
tree1a823e636b4518bcd0082dd43b0cca0e2f504118 /gcc/combine.c
parent2c0055380610a6430b885a2312175b71a47527a3 (diff)
downloadgcc-e6c0c44b5b43c4fef77f3a566d035db5c589ff99.zip
gcc-e6c0c44b5b43c4fef77f3a566d035db5c589ff99.tar.gz
gcc-e6c0c44b5b43c4fef77f3a566d035db5c589ff99.tar.bz2
re PR rtl-optimization/69535 (wrong code with -O -fno-tree-bit-ccp -fno-tree-reassoc due to use of uninitialised value)
PR rtl-opt/69535 * combine.c (make_compound_operation): When looking through a subreg, make sure to re-extend to the width of the outer mode. From-SVN: r233032
Diffstat (limited to 'gcc/combine.c')
-rw-r--r--gcc/combine.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/gcc/combine.c b/gcc/combine.c
index 858552d..c307793 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -7887,11 +7887,25 @@ make_compound_operation (rtx x, enum rtx_code in_code)
&& GET_CODE (SUBREG_REG (XEXP (x, 0))) == LSHIFTRT
&& (i = exact_log2 (UINTVAL (XEXP (x, 1)) + 1)) >= 0)
{
- new_rtx = make_compound_operation (XEXP (SUBREG_REG (XEXP (x, 0)), 0),
- next_code);
- new_rtx = make_extraction (GET_MODE (SUBREG_REG (XEXP (x, 0))), new_rtx, 0,
- XEXP (SUBREG_REG (XEXP (x, 0)), 1), i, 1,
- 0, in_code == COMPARE);
+ rtx inner_x0 = SUBREG_REG (XEXP (x, 0));
+ machine_mode inner_mode = GET_MODE (inner_x0);
+ new_rtx = make_compound_operation (XEXP (inner_x0, 0), next_code);
+ new_rtx = make_extraction (inner_mode, new_rtx, 0,
+ XEXP (inner_x0, 1),
+ i, 1, 0, in_code == COMPARE);
+
+ if (new_rtx)
+ {
+ /* If we narrowed the mode when dropping the subreg, then
+ we must zero-extend to keep the semantics of the AND. */
+ if (GET_MODE_SIZE (inner_mode) >= GET_MODE_SIZE (mode))
+ ;
+ else if (SCALAR_INT_MODE_P (inner_mode))
+ new_rtx = simplify_gen_unary (ZERO_EXTEND, mode,
+ new_rtx, inner_mode);
+ else
+ new_rtx = NULL;
+ }
/* If that didn't give anything, see if the AND simplifies on
its own. */