OSDN Git Service

* combine.c (force_to_mode): Use gen_int_mode.
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 22 May 2002 21:35:56 +0000 (21:35 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 22 May 2002 21:35:56 +0000 (21:35 +0000)
Don't clear CONST_INT bits outside of mode.

* gcc.dg/20020517-1.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@53750 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/combine.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/20020517-1.c [new file with mode: 0644]

index 5393a74..4c9bcc7 100644 (file)
@@ -1,3 +1,8 @@
+2002-05-22  Jakub Jelinek  <jakub@redhat.com>
+
+       * combine.c (force_to_mode): Use gen_int_mode.
+       Don't clear CONST_INT bits outside of mode.
+
 2002-05-22  Richard Henderson  <rth@redhat.com>
 
        * fixinc/inclhack.def (thread_keyword): Match __thread as last arg.
index bdb130c..f90460d 100644 (file)
@@ -6703,18 +6703,7 @@ force_to_mode (x, mode, mask, reg, just_select)
   /* If X is a CONST_INT, return a new one.  Do this here since the
      test below will fail.  */
   if (GET_CODE (x) == CONST_INT)
-    {
-      HOST_WIDE_INT cval = INTVAL (x) & mask;
-      int width = GET_MODE_BITSIZE (mode);
-
-      /* If MODE is narrower that HOST_WIDE_INT and CVAL is a negative
-        number, sign extend it.  */
-      if (width > 0 && width < HOST_BITS_PER_WIDE_INT
-         && (cval & ((HOST_WIDE_INT) 1 << (width - 1))) != 0)
-       cval |= (HOST_WIDE_INT) -1 << width;
-
-      return GEN_INT (cval);
-    }
+    return gen_int_mode (INTVAL (x) & mask, mode);
 
   /* If X is narrower than MODE and we want all the bits in X's mode, just
      get X in the proper mode.  */
@@ -6920,14 +6909,6 @@ force_to_mode (x, mode, mask, reg, just_select)
                                     force_to_mode (XEXP (x, 1), mode, mask,
                                                    reg, next_select));
 
-      /* 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;
index 0459dec..eb45471 100644 (file)
@@ -1,3 +1,7 @@
+2002-05-22  Jakub Jelinek  <jakub@redhat.com>
+
+       * gcc.dg/20020517-1.c: New test.
+
 2002-05-21  Richard Henderson  <rth@redhat.com>
 
        * gcc.dg/tls/tls.exp, gcc.dg/tls/trivial.c, gcc.dg/tls/diag-1.c,
diff --git a/gcc/testsuite/gcc.dg/20020517-1.c b/gcc/testsuite/gcc.dg/20020517-1.c
new file mode 100644 (file)
index 0000000..04386d8
--- /dev/null
@@ -0,0 +1,28 @@
+/* This testcase caused ICE in do_SUBST on IA-32, because 0xf6 constant
+   was not sign-extended for QImode.  */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+/* { dg-options "-O2 -mcpu=i686" { target i?86-*-* } } */
+
+#include <limits.h>
+
+void abort (void);
+void exit (int);
+
+void foo (void)
+{
+  int i;
+  char *p;
+
+  p = (char *) &i;
+  *p = -10;
+  if (* (unsigned char *) p != 0x100 - 10)
+    abort ();
+}
+
+int main (void)
+{
+  if (UCHAR_MAX == 255)
+    foo ();
+  exit (0);
+}