]> git.ipfire.org Git - thirdparty/gcc.git/commit
arm: remove some redundant zero_extend ops on thumb1
authorRichard Earnshaw <rearnsha@arm.com>
Mon, 3 Mar 2025 15:30:58 +0000 (15:30 +0000)
committerRichard Earnshaw <rearnsha@arm.com>
Mon, 3 Mar 2025 16:53:05 +0000 (16:53 +0000)
commit2a502f9e4c5c6a8e908ef1b0b5c03fb2e4bd4390
tree6ad134253ee817487c265682b941efb6467466ce
parentebc6c54e1f84170d591aa44c4a589c0164436a02
arm: remove some redundant zero_extend ops on thumb1

The code in gcc.target/unsigned-extend-1.c really should not need an
unsigned extension operations when the optimizers are used.  For Arm
and thumb2 that is indeed the case, but for thumb1 code it gets more
complicated as there are too many instructions for combine to look at.
For thumb1 we end up with two redundant zero_extend patterns which are
not removed: the first after the subtract instruction and the second of
the final boolean result.

We can partially fix this (for the second case above) by adding a new
split pattern for LEU and GEU patterns which work because the two
instructions for the [LG]EU pattern plus the redundant extension
instruction are combined into a single insn, which we can then split
using the 3->2 method back into the two insns of the [LG]EU sequence.

Because we're missing the optimization for all thumb1 cases (not just
those architectures with UXTB), I've adjust the testcase to detect all
the idioms that we might use for zero-extending a value, namely:

       UXTB
       AND ...#255 (in thumb1 this would require a register to hold 255)
       LSL ... #24; LSR ... #24

but I've also marked this test as XFAIL for thumb1 because we can't yet
eliminate the first of the two extend instructions.

gcc/
* config/arm/thumb1.md (split patterns for GEU and LEU): New.

gcc/testsuite:
* gcc.target/arm/unsigned-extend-1.c: Expand check for any
insn suggesting a zero-extend.  XFAIL for thumb1 code.
gcc/config/arm/thumb1.md
gcc/testsuite/gcc.target/arm/unsigned-extend-1.c