re PR target/36609 (AVR wrong code using incorrect RTL for test reversal pattern)

PR target/36609
* config/avr/avr.c (avr_reorg): Create RTL for reversed compare with zero.
* config/avr/avr.md  (QISI) : Define mode iterator.
(negated_tst<mode>) : Redefine as split using mode macro.
(reversed_tstqi): Define insn as reversed compare with zero.
(reversed_tsthi): Ditto.
(reversed_tstsi): Ditto.

From-SVN: r140124
This commit is contained in:
Andy Hutchinson 2008-09-08 22:25:42 +00:00 committed by Andy Hutchinson
parent 9cfa22be65
commit 3d7094661b
3 changed files with 37 additions and 7 deletions

View File

@ -1,3 +1,14 @@
2008-08-09 Andy Hutchinson <hutchinsonandy@aim.com>
PR target/36609
* config/avr/avr.c (avr_reorg): Create RTL for reversed compare with
zero.
* config/avr/avr.md (QISI) : Define mode iterator.
(negated_tst<mode>) : Redefine as split using mode macro.
(reversed_tstqi): Define insn as reversed compare with zero.
(reversed_tsthi): Ditto.
(reversed_tstsi): Ditto.
2008-09-08 Jakub Jelinek <jakub@redhat.com>
PR middle-end/37393

View File

@ -5683,7 +5683,7 @@ avr_reorg (void)
rtx t = XEXP (src,0);
PUT_CODE (t, swap_condition (GET_CODE (t)));
SET_SRC (pattern) = gen_rtx_NEG (GET_MODE (SET_SRC (pattern)),
SET_SRC (pattern) = gen_rtx_COMPARE (GET_MODE (SET_SRC (pattern)), const0_rtx,
SET_SRC (pattern));
INSN_CODE (next) = -1;
INSN_CODE (insn) = -1;

View File

@ -117,6 +117,9 @@
(const_int 2))]
(const_int 2)))
;; Define mode iterator
(define_mode_iterator QISI [(QI "") (HI "") (SI "")])
;;========================================================================
;; The following is used by nonlocal_goto and setjmp.
;; The receiver pattern will create no instructions since internally
@ -2015,9 +2018,10 @@
[(set_attr "cc" "compare")
(set_attr "length" "1")])
(define_insn "*negated_tstqi"
(define_insn "*reversed_tstqi"
[(set (cc0)
(neg:QI (match_operand:QI 0 "register_operand" "r")))]
(compare (const_int 0)
(match_operand:QI 0 "register_operand" "r")))]
""
"cp __zero_reg__,%0"
[(set_attr "cc" "compare")
@ -2031,9 +2035,10 @@
[(set_attr "cc" "compare,compare")
(set_attr "length" "1,2")])
(define_insn "*negated_tsthi"
(define_insn "*reversed_tsthi"
[(set (cc0)
(neg:HI (match_operand:HI 0 "register_operand" "r")))]
(compare (const_int 0)
(match_operand:HI 0 "register_operand" "r")))]
""
"cp __zero_reg__,%A0
cpc __zero_reg__,%B0"
@ -2048,9 +2053,10 @@
[(set_attr "cc" "compare")
(set_attr "length" "4")])
(define_insn "*negated_tstsi"
(define_insn "*reversed_tstsi"
[(set (cc0)
(neg:SI (match_operand:SI 0 "register_operand" "r")))]
(compare (const_int 0)
(match_operand:SI 0 "register_operand" "r")))]
""
"cp __zero_reg__,%A0
cpc __zero_reg__,%B0
@ -2187,6 +2193,19 @@
[(set_attr "cc" "compare,compare,compare,compare,compare")
(set_attr "length" "4,4,7,5,8")])
; Optimize negated tests into reverse compare if overflow is undefined.
(define_insn_and_split "negated_tst<mode>"
[(set (cc0)
(neg:QISI (match_operand:QISI 0 "register_operand")))]
"(!flag_wrapv && !flag_trapv && flag_strict_overflow)"
"#"
""
[(set (cc0)
(compare (const_int 0)
(match_dup 0)))]
"")
;; ----------------------------------------------------------------------
;; JUMP INSTRUCTIONS
;; ----------------------------------------------------------------------