aboutsummaryrefslogtreecommitdiff
path: root/gcc/combine.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@libertysurf.fr>2006-09-10 23:27:36 +0200
committerEric Botcazou <ebotcazou@gcc.gnu.org>2006-09-10 21:27:36 +0000
commitde097a3b99ba39804410a1a1c06412cd2dd9f1d1 (patch)
treed3c5020c21152292317e1a64bd9a4574e3d04193 /gcc/combine.c
parent4fe337f67a76d1b8288a3c63dec86dbaed77da4c (diff)
downloadgcc-de097a3b99ba39804410a1a1c06412cd2dd9f1d1.zip
gcc-de097a3b99ba39804410a1a1c06412cd2dd9f1d1.tar.gz
gcc-de097a3b99ba39804410a1a1c06412cd2dd9f1d1.tar.bz2
re PR rtl-optimization/28636 (Miscompiled loop)
PR rtl-optimization/28636 * combine.c (force_to_mode): Test for side-effects before substituting by zero. (simplify_shift_const): Likewise for zero or other constants. From-SVN: r116827
Diffstat (limited to 'gcc/combine.c')
-rw-r--r--gcc/combine.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/gcc/combine.c b/gcc/combine.c
index 727e625..0f4ea02 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -6860,7 +6860,7 @@ force_to_mode (rtx x, enum machine_mode mode, unsigned HOST_WIDE_INT mask,
nonzero = nonzero_bits (x, mode);
/* If none of the bits in X are needed, return a zero. */
- if (! just_select && (nonzero & mask) == 0)
+ if (!just_select && (nonzero & mask) == 0 && !side_effects_p (x))
x = const0_rtx;
/* If X is a CONST_INT, return a new one. Do this here since the
@@ -8637,14 +8637,14 @@ simplify_shift_const_1 (enum rtx_code code, enum machine_mode result_mode,
== 0))
code = LSHIFTRT;
- if (code == LSHIFTRT
- && GET_MODE_BITSIZE (shift_mode) <= HOST_BITS_PER_WIDE_INT
- && !(nonzero_bits (varop, shift_mode) >> count))
- varop = const0_rtx;
- if (code == ASHIFT
- && GET_MODE_BITSIZE (shift_mode) <= HOST_BITS_PER_WIDE_INT
- && !((nonzero_bits (varop, shift_mode) << count)
- & GET_MODE_MASK (shift_mode)))
+ if (((code == LSHIFTRT
+ && GET_MODE_BITSIZE (shift_mode) <= HOST_BITS_PER_WIDE_INT
+ && !(nonzero_bits (varop, shift_mode) >> count))
+ || (code == ASHIFT
+ && GET_MODE_BITSIZE (shift_mode) <= HOST_BITS_PER_WIDE_INT
+ && !((nonzero_bits (varop, shift_mode) << count)
+ & GET_MODE_MASK (shift_mode))))
+ && !side_effects_p (varop))
varop = const0_rtx;
switch (GET_CODE (varop))
@@ -9229,9 +9229,12 @@ simplify_shift_const_1 (enum rtx_code code, enum machine_mode result_mode,
if (outer_op == AND)
x = simplify_and_const_int (NULL_RTX, result_mode, x, outer_const);
else if (outer_op == SET)
- /* This means that we have determined that the result is
- equivalent to a constant. This should be rare. */
- x = GEN_INT (outer_const);
+ {
+ /* This means that we have determined that the result is
+ equivalent to a constant. This should be rare. */
+ if (!side_effects_p (x))
+ x = GEN_INT (outer_const);
+ }
else if (GET_RTX_CLASS (outer_op) == RTX_UNARY)
x = simplify_gen_unary (outer_op, result_mode, x, result_mode);
else