]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
or1k: Implement *extendbisi* to fix ICE in convert_mode_scalar [PR120587]
authorStafford Horne <shorne@gmail.com>
Wed, 18 Jun 2025 20:47:03 +0000 (21:47 +0100)
committerStafford Horne <shorne@gmail.com>
Fri, 20 Jun 2025 05:47:07 +0000 (06:47 +0100)
After commit 2dcc6dbd8a0 ("emit-rtl: Use simplify_subreg_regno to
validate hardware subregs [PR119966]") the OpenRISC port is broken
again.

Add extend* iinstruction patterns for the SR_F pseudo registers to avoid
having to use the subreg conversions which no longer work.

gcc/ChangeLog:

PR target/120587
* config/or1k/or1k.md (zero_extendbisi2_sr_f): New expand.
(extendbisi2_sr_f): New expand.
* config/or1k/predicates.md (sr_f_reg_operand): New predicate.

Signed-off-by: Stafford Horne <shorne@gmail.com>
gcc/config/or1k/or1k.md
gcc/config/or1k/predicates.md

index 627e40084b34bcd4913cd4d1ffb7d4275df3d1c7..a30cc18892daa579f7458b573db33a1a0d305259 100644 (file)
        (ne:SI (reg:BI SR_F_REGNUM) (const_int 0)))]
   "")
 
+;; Allowing "extending" the BImode SR_F to a general register
+;; avoids 'convert_mode_scalar' from trying to do subregging
+;; which we don't have support for.
+;; We require signed and unsigned extend instructions because
+;; signed comparisons require signed extention, but for SR_F
+;; it doesn't matter.
+
+(define_expand "zero_extendbisi2_sr_f"
+  [(set (match_operand:SI 0 "register_operand" "")
+       (zero_extend:SI (match_operand:BI 1 "sr_f_reg_operand" "")))]
+  ""
+{
+  emit_insn(gen_sne_sr_f (operands[0]));
+  DONE;
+})
+
+(define_expand "extendbisi2_sr_f"
+  [(set (match_operand:SI 0 "register_operand" "")
+       (sign_extend:SI (match_operand:BI 1 "sr_f_reg_operand" "")))]
+  ""
+{
+  emit_insn(gen_sne_sr_f (operands[0]));
+  DONE;
+})
+
 (define_insn_and_split "*scc"
   [(set (match_operand:SI 0 "register_operand" "=r")
        (match_operator:SI 1 "equality_comparison_operator"
index 144f4d7b57789a0d358d3c43bea1dc06081c3986..7ccfd09985dd9a2576ce4dc33580d9e7c27a8326 100644 (file)
     (and (match_operand 0 "register_operand")
         (match_test "TARGET_ROR"))))
 
+(define_predicate "sr_f_reg_operand"
+  (and (match_operand 0 "register_operand")
+       (match_test "REGNO (op) == SR_F_REGNUM")))
+
 (define_predicate "call_insn_operand"
   (ior (and (match_code "symbol_ref")
            (match_test "!TARGET_CMODEL_LARGE"))