]> git.ipfire.org Git - thirdparty/gcc.git/commit
[PATCH] rx: avoid adding setpsw for rx_cmpstrn when len is const
authorKeith Packard <keithp@keithp.com>
Wed, 16 Apr 2025 20:10:18 +0000 (14:10 -0600)
committerJeff Law <jlaw@ventanamicro.com>
Wed, 16 Apr 2025 20:10:18 +0000 (14:10 -0600)
commit83340869a21baafc889c05b6b5c632a226c509bc
tree8f92f126ee8abc6747d2f4e90dc2f7db248d6dda
parentd5d7dfab811de74cff88759785d0d5068b3b1121
[PATCH] rx: avoid adding setpsw for rx_cmpstrn when len is const

pattern using rx_cmpstrn is cmpstrsi for which len is a constant -1,
so we'll be moving the setpsw instructions from rx_cmpstrn to
cmpstrnsi as follows:

 1. Adjust the predicate on the length operand from "register_operand"
    to "nonmemory_operand". This will allow constants to appear here,
    instead of having them already transferred into a register.

 2. Check to see if the len value is constant, and then check if it is
    actually zero. In that case, short-circuit the rest of the pattern
    and set the result register to 0.

 3. Emit 'setpsw c' and 'setpsw z' instructions when the len is not a
    constant, in case it turns out to be zero at runtime.

 4. Remove the two 'setpsw' instructions from rx_cmpstrn.

gcc/
* config/rx/rx.md (cmpstrnsi): Allow constant length.  For
static length 0, just store 0 into the output register.
For dynamic zero, set C/Z appropriately.
(rxcmpstrn): No longer set C/Z.
gcc/config/rx/rx.md