]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[PATCH] rx: allow cmpstrnsi len to be zero
authorKeith Packard <keithp@keithp.com>
Sat, 15 Feb 2025 16:17:41 +0000 (09:17 -0700)
committerJeff Law <jlaw@ventanamicro.com>
Sat, 15 Feb 2025 16:17:41 +0000 (09:17 -0700)
The SCMPU instruction doesn't change the C and Z flags when the
incoming length is zero, which means the insn will produce a
value based upon the existing flag values.

As a quick kludge, adjust these flags to ensure a zero result in this
case.

gcc/
* config/rx/rx.md (rx_cmpstrn): Correctly handle len=0 case.

gcc/config/rx/rx.md

index 89211585c9ceff90aaf246f81de6c4b53e21b600..edb2c96603f5b93e0e4fa30db88b880867e2e7b0 100644 (file)
    (clobber (reg:SI 3))
    (clobber (reg:CC CC_REG))]
   "rx_allow_string_insns"
-  "scmpu               ; Perform the string comparison
+  "setpsw  z           ; Set flags in case len is zero
+   setpsw  c
+   scmpu               ; Perform the string comparison
    mov     #-1, %0      ; Set up -1 result (which cannot be created
                         ; by the SC insn)
    bnc    ?+           ; If Carry is not set skip over