]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR rtl-optimization/8746 (gcc miscompiles Linux kernel ppa driver on x86)
authorEric Botcazou <ebotcazou@libertysurf.fr>
Wed, 19 Mar 2003 19:54:27 +0000 (20:54 +0100)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Wed, 19 Mar 2003 19:54:27 +0000 (19:54 +0000)
PR optimization/8746
Backport from mainline:

Thu Jun  6 23:14:46 CEST 2002  Jan Hubicka<jh@suse.cz>

* i386.md (and promoting splitters): Disable QI to SImode promoting
when doing so changes immediate to be 32bit.

From-SVN: r64593

gcc/ChangeLog
gcc/config/i386/i386.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/i386-signbit-1.c [new file with mode: 0644]

index 3449fec285a9e571ccfc54784ceec7436ab7d794..d51e167d32e81eabdac4fe6cd948d327d9940357 100644 (file)
@@ -1,3 +1,13 @@
+2003-03-19  Eric Botcazou  <ebotcazou@libertysurf.fr>
+
+       PR optimization/8746
+       Backport from mainline:
+
+       Thu Jun  6 23:14:46 CEST 2002  Jan Hubicka<jh@suse.cz>
+
+       * i386.md (and promoting splitters): Disable QI to SImode promoting
+       when doing so changes immediate to be 32bit.
+
 2003-03-19  Jakub Jelinek  <jakub@redhat.com>
 
        * stmt.c (expand_start_case): Call emit_queue ().
index d615a5017a8686874fab077a00abb9415ba7d9ce..34cd0da1aeeacb38484bbe6b99abffc9ad5b1aa6 100644 (file)
    && ix86_match_ccmode (insn, CCNOmode)
    && (GET_MODE (operands[0]) == HImode
        || (GET_MODE (operands[0]) == QImode 
+          /* Ensure that the operand will remain sign extended immediate.  */
+          && INTVAL (operands[2]) >= 0
           && (TARGET_PROMOTE_QImode || optimize_size)))"
   [(parallel [(set (reg:CCNO 17)
                   (compare:CCNO (and:SI (match_dup 1) (match_dup 2))
    operands[0] = gen_lowpart (SImode, operands[0]);
    operands[1] = gen_lowpart (SImode, operands[1]);")
 
+; Don't promote the QImode tests, as i386 don't have encoding of
+; the test instruction with 32bit sign extended immediate and thus
+; the code grows.
 (define_split
   [(set (reg 17)
-       (compare (and (match_operand 0 "aligned_operand" "")
-                     (match_operand 1 "const_int_operand" ""))
+       (compare (and (match_operand:HI 0 "aligned_operand" "")
+                     (match_operand:HI 1 "const_int_operand" ""))
                 (const_int 0)))]
   "! TARGET_PARTIAL_REG_STALL && reload_completed
    && ix86_match_ccmode (insn, CCNOmode)
-   && (GET_MODE (operands[0]) == HImode
-       || (GET_MODE (operands[0]) == QImode 
-          && (TARGET_PROMOTE_QImode || optimize_size)))"
+   && GET_MODE (operands[0]) == HImode"
   [(set (reg:CCNO 17)
        (compare:CCNO (and:SI (match_dup 0) (match_dup 1))
                      (const_int 0)))]
index e2a81bf5e4ffb83af246337ec7d08e30aaf82de6..6286e197afe82617b3e1d67b2af68602e597dec5 100644 (file)
@@ -1,3 +1,7 @@
+2003-03-19  Eric Botcazou  <ebotcazou@libertysurf.fr>
+
+       * gcc.dg/i386-signbit-1.c: New test.
+
 2003-03-19  Jakub Jelinek  <jakub@redhat.com>
 
        * gcc.c-torture/execute/20030313-1.c: New test.
diff --git a/gcc/testsuite/gcc.dg/i386-signbit-1.c b/gcc/testsuite/gcc.dg/i386-signbit-1.c
new file mode 100644 (file)
index 0000000..ef16229
--- /dev/null
@@ -0,0 +1,28 @@
+/* PR optimization/8746 */
+/* { dg-do run } */
+/* { dg-options "-mcpu=i586 -O" { target i?86-*-* } } */
+
+extern void abort (void);
+
+unsigned char r0;
+
+int foo(int x)
+{
+  unsigned char r = x&0xf0;
+
+  if (!(r&0x80))
+  {
+    r0 = r;
+    return 0;
+  }
+  else
+    return 1;
+}
+
+int main(void)
+{
+  if (foo(0x80) != 1)
+    abort();
+
+   return 0;
+}