+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 ().
&& 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)))]
--- /dev/null
+/* 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;
+}