diff options
author | Roger Sayle <roger@nextmovesoftware.com> | 2023-04-30 23:47:13 +0100 |
---|---|---|
committer | Roger Sayle <roger@nextmovesoftware.com> | 2023-04-30 23:47:13 +0100 |
commit | b159026b739f46e6d552bb23e8f51f03e291f51e (patch) | |
tree | fc6a3bfba4695d28662e6ce2e720aa382b856d83 /gcc/config/stormy16 | |
parent | d56af02fb1fd6eb50beb8a1689cf646bc567dbfc (diff) | |
download | gcc-b159026b739f46e6d552bb23e8f51f03e291f51e.zip gcc-b159026b739f46e6d552bb23e8f51f03e291f51e.tar.gz gcc-b159026b739f46e6d552bb23e8f51f03e291f51e.tar.bz2 |
[Committed] Update xstormy16's neghi2 pattern to not clobber the carry flag.
When I converted xstormy's neghi2 pattern from a define_expand to a
define_insn, I forgot that define_expand implicitly produces a
sequence of instructions, but a define_insn is an implicit parallel,
thereby messing up the clobber (reg:BI CARRY_REG), which can then cause
an ICE in the auto-generated added_clobbers_hard_reg_p. Whilst stripping
the superfluous PARALLEL resolves this issue, an even better fix is to
use xstormy16's INC instruction, that (like NOT) doesn't affect the carry
flag, resulting in a neghi2 implementation that can more easily be CSE'd
and scheduled.
Many thanks (again) to Jeff Law for testing/reporting this issue.
2024-04-30 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
* config/stormy16/stormy16.md (neghi2): Rewrite pattern using
inc to avoid clobbering the carry flag.
gcc/testsuite/ChangeLog
* gcc.target/xstormy16/neghi2.c: Update expected implementation.
Diffstat (limited to 'gcc/config/stormy16')
-rw-r--r-- | gcc/config/stormy16/stormy16.md | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/gcc/config/stormy16/stormy16.md b/gcc/config/stormy16/stormy16.md index be1ee04..91e4bb1 100644 --- a/gcc/config/stormy16/stormy16.md +++ b/gcc/config/stormy16/stormy16.md @@ -519,11 +519,10 @@ ;; Negation (define_insn "neghi2" - [(parallel [(set (match_operand:HI 0 "register_operand" "=r") - (neg:HI (match_operand:HI 1 "register_operand" "0"))) - (clobber (reg:BI CARRY_REG))])] + [(set (match_operand:HI 0 "register_operand" "=r") + (neg:HI (match_operand:HI 1 "register_operand" "0")))] "" - "not %0 | add %0,#1" + "not %0 | inc %0" [(set_attr "length" "4")]) ;; :::::::::::::::::::: |