From: Eric Botcazou Date: Wed, 19 Mar 2003 19:54:27 +0000 (+0100) Subject: re PR rtl-optimization/8746 (gcc miscompiles Linux kernel ppa driver on x86) X-Git-Tag: releases/gcc-3.2.3~92 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f4e4a9eec38ec6aac23280eae8044d38bb3eafe3;p=thirdparty%2Fgcc.git re PR rtl-optimization/8746 (gcc miscompiles Linux kernel ppa driver on x86) PR optimization/8746 Backport from mainline: Thu Jun 6 23:14:46 CEST 2002 Jan Hubicka * i386.md (and promoting splitters): Disable QI to SImode promoting when doing so changes immediate to be 32bit. From-SVN: r64593 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3449fec285a9..d51e167d32e8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2003-03-19 Eric Botcazou + + PR optimization/8746 + Backport from mainline: + + Thu Jun 6 23:14:46 CEST 2002 Jan Hubicka + + * i386.md (and promoting splitters): Disable QI to SImode promoting + when doing so changes immediate to be 32bit. + 2003-03-19 Jakub Jelinek * stmt.c (expand_start_case): Call emit_queue (). diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index d615a5017a86..34cd0da1aeea 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -16875,6 +16875,8 @@ && 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)) @@ -16888,16 +16890,17 @@ 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)))] diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e2a81bf5e4ff..6286e197afe8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2003-03-19 Eric Botcazou + + * gcc.dg/i386-signbit-1.c: New test. + 2003-03-19 Jakub Jelinek * 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 index 000000000000..ef162297dc48 --- /dev/null +++ b/gcc/testsuite/gcc.dg/i386-signbit-1.c @@ -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; +}