aboutsummaryrefslogtreecommitdiff
path: root/gcc/combine.c
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1992-08-24 06:48:59 -0400
committerRichard Kenner <kenner@gcc.gnu.org>1992-08-24 06:48:59 -0400
commit5874448344f74d0033faaadc5d009bcd3d2726bb (patch)
tree78aa3dbf4dff3232639b8191a1c3512ff068dc3d /gcc/combine.c
parentc7d2d61d20c859ef2a9796c03b573204e7f2ae8c (diff)
downloadgcc-5874448344f74d0033faaadc5d009bcd3d2726bb.zip
gcc-5874448344f74d0033faaadc5d009bcd3d2726bb.tar.gz
gcc-5874448344f74d0033faaadc5d009bcd3d2726bb.tar.bz2
(subst): When moving operation inside IF_THEN_ELSE, make a new rtx
instead of using SUBST due to sharing. (simplify_comparison): Correct test for sign extension when trying to widen comparison. From-SVN: r1938
Diffstat (limited to 'gcc/combine.c')
-rw-r--r--gcc/combine.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/gcc/combine.c b/gcc/combine.c
index 5b9b9a4..2af4949 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -2616,16 +2616,18 @@ subst (x, from, to, in_dest, unique_copy)
if ((GET_RTX_CLASS (code) == '2' || GET_RTX_CLASS (code) == 'c')
&& GET_CODE (XEXP (x, 0)) == IF_THEN_ELSE)
{
- SUBST (XEXP (XEXP (x, 0), 1),
- subst (gen_binary (code, mode, XEXP (XEXP (x, 0), 1),
- XEXP (x, 1)),
- pc_rtx, pc_rtx, 0));
- SUBST (XEXP (XEXP (x, 0), 2),
- subst (gen_binary (code, mode, XEXP (XEXP (x, 0), 2),
- XEXP (x, 1)),
- pc_rtx, pc_rtx, 0));
-
- x = XEXP (x, 0);
+ /* Don't do this by using SUBST inside X since we might be messing
+ up a shared expression. */
+ rtx cond = XEXP (XEXP (x, 0), 0);
+ rtx t_arm = subst (gen_binary (code, mode, XEXP (XEXP (x, 0), 1),
+ XEXP (x, 1)),
+ pc_rtx, pc_rtx, 0);
+ rtx f_arm = subst (gen_binary (code, mode, XEXP (XEXP (x, 0), 2),
+ XEXP (x, 1)),
+ pc_rtx, pc_rtx, 0);
+
+
+ x = gen_rtx (IF_THEN_ELSE, mode, cond, t_arm, f_arm);
goto restart;
}
@@ -2633,14 +2635,13 @@ subst (x, from, to, in_dest, unique_copy)
&& GET_CODE (XEXP (x, 0)) == IF_THEN_ELSE
&& GET_MODE (XEXP (x, 0)) == mode)
{
- SUBST (XEXP (XEXP (x, 0), 1),
- subst (gen_unary (code, mode, XEXP (XEXP (x, 0), 1)),
- pc_rtx, pc_rtx, 0));
- SUBST (XEXP (XEXP (x, 0), 2),
- subst (gen_unary (code, mode, XEXP (XEXP (x, 0), 2)),
- pc_rtx, pc_rtx, 0));
-
- x = XEXP (x, 0);
+ rtx cond = XEXP (XEXP (x, 0), 0);
+ rtx t_arm = subst (gen_unary (code, mode, XEXP (XEXP (x, 0), 1)),
+ pc_rtx, pc_rtx, 0);
+ rtx f_arm = subst (gen_unary (code, mode, XEXP (XEXP (x, 0), 2)),
+ pc_rtx, pc_rtx, 0);
+
+ x = gen_rtx_combine (IF_THEN_ELSE, mode, cond, t_arm, f_arm);
goto restart;
}
@@ -7956,9 +7957,9 @@ simplify_comparison (code, pop0, pop1)
|| ((code == EQ || code == NE
|| code == GE || code == GT || code == LE || code == LT)
&& (num_sign_bit_copies (op0, tmode)
- >= GET_MODE_BITSIZE (tmode) - GET_MODE_BITSIZE (mode))
+ > GET_MODE_BITSIZE (tmode) - GET_MODE_BITSIZE (mode))
&& (num_sign_bit_copies (op1, tmode)
- >= GET_MODE_BITSIZE (tmode) - GET_MODE_BITSIZE (mode))))
+ > GET_MODE_BITSIZE (tmode) - GET_MODE_BITSIZE (mode))))
{
op0 = gen_lowpart_for_combine (tmode, op0);
op1 = gen_lowpart_for_combine (tmode, op1);