]> git.ipfire.org Git - thirdparty/gcc.git/commit
CRIS: Improve bailing for eliminable compares for "addi" vs. "add"
authorHans-Peter Nilsson <hp@axis.com>
Tue, 28 Mar 2023 01:20:05 +0000 (03:20 +0200)
committerHans-Peter Nilsson <hp@bitrange.com>
Tue, 28 Mar 2023 01:20:05 +0000 (03:20 +0200)
commit75be4badfeda2448383429f6061e095afd5a4ee5
tree39d64d4e527d24cea969ecf2ef82a3b21242de3c
parentbab2fb9d63ef1e3d51b88dcdf1d7d533fb6e6844
CRIS: Improve bailing for eliminable compares for "addi" vs. "add"

This patch affects a post-reload define_split for CRIS that transforms
a condition-code-clobbering addition into a non-clobbering addition.
(A "two-operand" addition between registers is the only insn that has
both a condition-code-clobbering and a non-clobbering variant for
CRIS.)  Many more "add.d":s are replaced by non-condition-code-
clobbering "addi":s after this patch, but most of the transformations
don't matter.

CRIS with LRA generated code that exposed a flaw with the original
patch: it bailed too easily, on *any* insn using the result of the
addition.  To wit, more effort than simply applying reg_mentioned_p is
needed to inspect the user, in the code to avoid munging an insn
sequence that cmpelim is supposed to handle.

With this patch coremark score for CRIS (*with reload*) improves by
less than 0.01% (a single "nop" is eliminated in
core_state_transition, in an execution path that affects ~1/20 of all
of the 10240 calls).  However, the original cause for this patch is to
not regress gcc.target/cris/pr93372-44.c for LRA, where otherwise a
needless "cmpq" is emitted.  For CRIS with LRA, the performance effect
on coremark isn't even measurable, except by reducing the size of the
executable due to affecting non-called library code.

* config/cris/cris.md ("*add<mode>3_addi"): Improve to bail only
for possible eliminable compares.
gcc/config/cris/cris.md