Eliminate more comparisons on the H8 port
commit204303c81e82ddd01e7dc5a5a63719d476f9043c
authorJeff Law <jlaw@ventanamicro>
Tue, 9 May 2023 13:18:45 +0000 (9 07:18 -0600)
committerJeff Law <jlaw@ventanamicro>
Tue, 9 May 2023 13:18:45 +0000 (9 07:18 -0600)
treeabc87de323cc440f65e603ae73575c61445ada4c
parent2ed5ceba0fe313ef09bdfe98788ba9377bfec9aa
Eliminate more comparisons on the H8 port

This patch fixes a minor code quality issue I found while testing LRA on the
H8.  Specifically we have a peephole which converts a comparison of a memory
location against zero into a load + comparison which is actually more
efficient.  This triggers when there are registers available at the right
point during peephole2.

If the load is not a mode dependent address we can actually do better by
realizing the load itself sets the proper flags and eliminate the comparison.
I may have expected this to happen when I wrote the original peephole2,
but cmpelim runs before peephole2, so clearly if we want to eliminate the
comparison we have to do it manually.

gcc/
* config/h8300/testcompare.md: Add peephole2 which uses a memory
load to set flags, thus eliminating a compare against zero.
gcc/config/h8300/testcompare.md