https://gcc.gnu.org/g:457032949147f0bccabc83db03b981c8aaf73629

commit r17-4969-g457032949147f0bccabc83db03b981c8aaf73629
Author: Jeff Law <[email protected]>
Date:   Wed Oct 7 14:07:02 2026 -0600

    [SH] Force using IOR for AOP expansion for SH port
    
    The most recent changes for pr108477 tripped regressions on the sh port:
    
    Tests that now fail, but worked before (10 tests):
    
    gcc: gcc.target/sh/pr54089-1.c scan-assembler-not and\t#1
    gcc: gcc.target/sh/pr54089-1.c scan-assembler-times rotcr 25
    gcc: gcc.target/sh/pr54089-1.c scan-assembler-times sett 1
    gcc: gcc.target/sh/pr54089-1.c scan-assembler-times shll\t 1
    gcc: gcc.target/sh/pr54089-7.c scan-assembler-not and
    gcc: gcc.target/sh/pr54089-7.c scan-assembler-not movt
    gcc: gcc.target/sh/pr54089-7.c scan-assembler-not rotr
    gcc: gcc.target/sh/pr54089-7.c scan-assembler-times rotcr 4
    gcc: gcc.target/sh/pr54089-8.c scan-assembler-times rotcl 28
    gcc: gcc.target/sh/pr54089-9.c scan-assembler-times rotcl 4
    
    I spot checked pr54089-1 and every case I looked at was better before the 
change compared to after the change.  So I chose the path of forcing the AOP 
expander to use IOR.  That fixes the regressions seen on sh3/sh3eb.  Those 
regressions would almost certainly pop on sh4/sh4eb, but those haven't 
triggered in their weekly cycle yet.
    
    Pushing to the trunk after verifying all the sh3/sh3eb regressions are 
fixed.
    
    gcc/
            * config/sh/sh.md (aopsi3): Define and route towards IOR.

Diff:
---
 gcc/config/sh/sh.md | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/gcc/config/sh/sh.md b/gcc/config/sh/sh.md
index 85980f31953b..5acca403608d 100644
--- a/gcc/config/sh/sh.md
+++ b/gcc/config/sh/sh.md
@@ -2776,6 +2776,19 @@
   "xor %2,%0"
   [(set_attr "type" "arith")])
 
+;; When we can use PLUS, IOR, or XOR interchangably, use IOR.
+(define_expand "aopsi3"
+  [(set (match_operand:SI 0 "arith_reg_dest")
+       (ior:SI (match_operand:SI 1 "arith_reg_operand")
+               (match_operand:SI 2 "logical_operand")))]
+  ""
+  {
+    emit_insn (gen_iorsi3 (operands[0], operands[1], operands[2]));
+    DONE;
+  }
+)
+
+
 ;; The *logical_op_t pattern helps combine eliminating sign/zero extensions
 ;; of results where one of the inputs is a T bit store.  Notice that this
 ;; pattern must not match during reload.  If reload picks this pattern it

Reply via email to