aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/avr
diff options
context:
space:
mode:
authorAndy Hutchinson <hutchinsonandy@aim.com>2008-09-08 22:25:42 +0000
committerAndy Hutchinson <hutchinsonandy@gcc.gnu.org>2008-09-08 22:25:42 +0000
commit3d7094661bbf3472142f85a0ad940d19ecc87ba8 (patch)
tree22fc2e809230cf26079d5e06f5f74c10a01597b5 /gcc/config/avr
parent9cfa22be65408f2f21ef2c0cc0493ee39063174e (diff)
downloadgcc-3d7094661bbf3472142f85a0ad940d19ecc87ba8.zip
gcc-3d7094661bbf3472142f85a0ad940d19ecc87ba8.tar.gz
gcc-3d7094661bbf3472142f85a0ad940d19ecc87ba8.tar.bz2
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
Diffstat (limited to 'gcc/config/avr')
-rw-r--r--gcc/config/avr/avr.c2
-rw-r--r--gcc/config/avr/avr.md31
2 files changed, 26 insertions, 7 deletions
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<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
;; ----------------------------------------------------------------------