From: hutchinsonandy Date: Mon, 8 Sep 2008 22:25:42 +0000 (+0000) Subject: PR target/36609 X-Git-Tag: upstream/4.9.2~39801 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d702140c13e2d9734994fe420fc14a9bb45d4961;p=platform%2Fupstream%2Flinaro-gcc.git 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) : Redefine as split using mode macro. (reversed_tstqi): Define insn as reversed compare with zero. (reversed_tsthi): Ditto. (reversed_tstsi): Ditto. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@140124 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d5c28ee..a34ad21 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2008-08-09 Andy Hutchinson + + 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) : 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 PR middle-end/37393 diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index cc8b65c..fb217bb 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -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; diff --git a/gcc/config/avr/avr.md b/gcc/config/avr/avr.md index 371ca76..8dad9d8 100644 --- a/gcc/config/avr/avr.md +++ b/gcc/config/avr/avr.md @@ -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" + [(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 ;; ----------------------------------------------------------------------