aboutsummaryrefslogtreecommitdiff
path: root/gcc/combine.c
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1993-11-19 18:24:20 -0500
committerRichard Kenner <kenner@gcc.gnu.org>1993-11-19 18:24:20 -0500
commit2dd484ed8ede94cd8940bbdfd8fa3d41c812430c (patch)
tree4dd7347c0739a0c602c80e2dc6f3e44902b18b27 /gcc/combine.c
parent35fc1624acabf68663c05b029b75763bff8fd6ab (diff)
downloadgcc-2dd484ed8ede94cd8940bbdfd8fa3d41c812430c.zip
gcc-2dd484ed8ede94cd8940bbdfd8fa3d41c812430c.tar.gz
gcc-2dd484ed8ede94cd8940bbdfd8fa3d41c812430c.tar.bz2
(force_to_mode): Don't allow sign-extension of constants when we are
narrowing things in an IOR or XOR. From-SVN: r6117
Diffstat (limited to 'gcc/combine.c')
-rw-r--r--gcc/combine.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/combine.c b/gcc/combine.c
index 1d22a13..86be74a 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -5790,6 +5790,14 @@ force_to_mode (x, mode, mask, reg)
op1 = gen_lowpart_for_combine (op_mode, force_to_mode (XEXP (x, 1),
mode, mask, reg));
+ /* If OP1 is a CONST_INT and X is an IOR or XOR, clear bits outside
+ MASK since OP1 might have been sign-extended but we never want
+ to turn on extra bits, since combine might have previously relied
+ on them being off. */
+ if (GET_CODE (op1) == CONST_INT && (code == IOR || code == XOR)
+ && (INTVAL (op1) & mask) != 0)
+ op1 = GEN_INT (INTVAL (op1) & mask);
+
if (op_mode != GET_MODE (x) || op0 != XEXP (x, 0) || op1 != XEXP (x, 1))
x = gen_binary (code, op_mode, op0, op1);
break;