(force_to_mode): Don't allow sign-extension of constants when we are
authorRichard Kenner <kenner@gcc.gnu.org>
Fri, 19 Nov 1993 23:24:20 +0000 (18:24 -0500)
committerRichard Kenner <kenner@gcc.gnu.org>
Fri, 19 Nov 1993 23:24:20 +0000 (18:24 -0500)
narrowing things in an IOR or XOR.

From-SVN: r6117

gcc/combine.c

index 1d22a1358b398a02fadbd9731820f7956b374995..86be74a60b85fb1506e127c032723dde9bd99ad4 100644 (file)
@@ -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;