]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[committed] Fix various sh define_insn_and_split predicates
authorJeff Law <jlaw@ventanamicro.com>
Sat, 6 Jul 2024 12:35:54 +0000 (06:35 -0600)
committerJeff Law <jlaw@ventanamicro.com>
Sat, 6 Jul 2024 12:39:32 +0000 (06:39 -0600)
The sh4-linux-gnu port has failed to bootstrap since the introduction of late
combine due to failures to split certain insns.

This is caused by incorrect predicates in various define_insn_and_split
patterns.  Essentially the insn's predicate is something like "TARGET_SH1".
The split predicate is "&& can_create_pseudos_p ()".  So these patterns will
match post-reload, but be un-splittable.  So at assembly output time, we get
the failure as the output template is "#".

This patch fixes the most obvious & egregious cases by bringing the split
condition into the insn's predicate and leaving "&& 1" as the split condition.
That's enough to get sh4-linux-gnu bootstrapping again and I'm hoping it does
the same for sh4eb-linux-gnu.

Pushing to the trunk.

gcc/
* config/sh/sh.md (adddi3): Only allow matching when we can
still create new pseudos.
(subdi3, *rotcl, *rotcr, *rotcr_neg_t, negdi2): Likewise.
(abs<mode>2, negabs<mode>2, negdi_cond): Likewise.
(*swapbisi2_and_shl8, *swapbhisi2, *movsi_index_disp_load): Likewise.
(*movhi_index_disp_load, *mov<mode>index_disp_store): Likewise.
(*mov_t_msb_neg, *negt_msb, clipu_one): Likewise.

gcc/config/sh/sh.md

index 9491b49e55b681a0013591a364c5589872de589e..3e978254ab0c8b1e8ce8b6a6915fb31e92c7582a 100644 (file)
        (plus:DI (match_operand:DI 1 "arith_reg_operand")
                 (match_operand:DI 2 "arith_reg_operand")))
    (clobber (reg:SI T_REG))]
-  "TARGET_SH1"
+  "TARGET_SH1 && can_create_pseudo_p ()"
   "#"
-  "&& can_create_pseudo_p ()"
+  "&& 1"
   [(const_int 0)]
 {
   emit_insn (gen_clrt ());
        (minus:DI (match_operand:DI 1 "arith_reg_operand")
                  (match_operand:DI 2 "arith_reg_operand")))
    (clobber (reg:SI T_REG))]
-  "TARGET_SH1"
+  "TARGET_SH1 && can_create_pseudo_p ()"
   "#"
-  "&& can_create_pseudo_p ()"
+  "&& 1"
   [(const_int 0)]
 {
   emit_insn (gen_clrt ());
                (and:SI (match_operand:SI 3 "arith_reg_or_t_reg_operand")
                        (const_int 1))))
    (clobber (reg:SI T_REG))]
-  "TARGET_SH1"
+  "TARGET_SH1 && can_create_pseudo_p ()"
   "#"
-  "&& can_create_pseudo_p ()"
+  "&& 1"
   [(const_int 0)]
 {
   gcc_assert (INTVAL (operands[2]) > 0);
                           (match_operand:SI 2 "const_int_operand"))
                (match_operand 3 "treg_set_expr")))
    (clobber (reg:SI T_REG))]
-  "TARGET_SH1"
+  "TARGET_SH1 && can_create_pseudo_p ()"
   "#"
-  "&& can_create_pseudo_p ()"
+  "&& 1"
   [(parallel [(set (match_dup 0)
                   (ior:SI (ashift:SI (match_dup 1) (match_dup 2))
                           (and:SI (match_dup 3) (const_int 1))))
                (ashift:SI (match_operand:SI 2 "arith_reg_operand")
                           (match_operand:SI 3 "const_int_operand"))))
    (clobber (reg:SI T_REG))]
-  "TARGET_SH1"
+  "TARGET_SH1 && can_create_pseudo_p ()"
   "#"
-  "&& can_create_pseudo_p ()"
+  "&& 1"
   [(parallel [(set (match_dup 0)
                   (ior:SI (ashift:SI (match_dup 2) (match_dup 3))
                           (and:SI (match_dup 1) (const_int 1))))
                (lshiftrt:SI (match_operand:SI 3 "arith_reg_operand")
                             (const_int 31))))
    (clobber (reg:SI T_REG))]
-  "TARGET_SH1"
+  "TARGET_SH1 && can_create_pseudo_p ()"
   "#"
-  "&& can_create_pseudo_p ()"
+  "&& 1"
   [(parallel [(set (match_dup 0)
                   (ior:SI (ashift:SI (match_dup 1) (match_dup 2))
                           (and:SI (reg:SI T_REG) (const_int 1))))
                (ashift:SI (match_operand:SI 1 "arith_reg_operand")
                           (match_operand:SI 2 "const_int_operand"))))
    (clobber (reg:SI T_REG))]
-  "TARGET_SH1"
+  "TARGET_SH1 && can_create_pseudo_p ()"
   "#"
-  "&& can_create_pseudo_p ()"
+  "&& 1"
   [(parallel [(set (match_dup 0)
                   (ior:SI (ashift:SI (match_dup 1) (match_dup 2))
                           (and:SI (reg:SI T_REG) (const_int 1))))
                                 (const_int 1)
                                 (match_operand 4 "const_int_operand"))))
    (clobber (reg:SI T_REG))]
-  "TARGET_SH1"
+  "TARGET_SH1 && can_create_pseudo_p ()"
   "#"
-  "&& can_create_pseudo_p ()"
+  "&& 1"
   [(parallel [(set (match_dup 0)
                   (ior:SI (ashift:SI (match_dup 1) (match_dup 2))
                           (and:SI (match_dup 5) (const_int 1))))
                (lshiftrt:SI (match_operand:SI 2 "arith_reg_operand")
                             (const_int 1))))
    (clobber (reg:SI T_REG))]
-  "TARGET_SH1"
+  "TARGET_SH1 && can_create_pseudo_p ()"
   "#"
-  "&& can_create_pseudo_p ()"
+  "&& 1"
   [(const_int 0)]
 {
   rtx tmp = gen_reg_rtx (SImode);
                             (const_int 1))
                (const_int -2147483648))) ;; 0xffffffff80000000
    (clobber (reg:SI T_REG))]
-  "TARGET_SH1"
+  "TARGET_SH1 && can_create_pseudo_p ()"
   "#"
-  "&& can_create_pseudo_p ()"
+  "&& 1"
   [(const_int 0)]
 {
   emit_insn (gen_sett ());
                (lshiftrt:SI (match_operand:SI 2 "arith_reg_operand")
                             (match_operand:SI 3 "const_int_operand"))))
    (clobber (reg:SI T_REG))]
-  "TARGET_SH1"
+  "TARGET_SH1 && can_create_pseudo_p ()"
   "#"
-  "&& can_create_pseudo_p ()"
+  "&& 1"
   [(parallel [(set (match_dup 0)
                   (ior:SI (lshiftrt:SI (match_dup 2) (match_dup 3))
                           (ashift:SI (reg:SI T_REG) (const_int 31))))
                             (match_operand:SI 2 "const_int_operand"))
                (match_operand:SI 3 "negt_reg_shl31_operand")))
    (clobber (reg:SI T_REG))]
-  "TARGET_SH1"
+  "TARGET_SH1 && can_create_pseudo_p ()"
   "#"
-  "&& can_create_pseudo_p ()"
+  "&& 1"
   [(parallel [(set (match_dup 0)
                   (ior:SI (lshiftrt:SI (match_dup 1) (match_dup 2))
                           (ashift:SI (reg:SI T_REG) (const_int 31))))
   [(set (match_operand:DI 0 "arith_reg_dest")
        (neg:DI (match_operand:DI 1 "arith_reg_operand")))
    (clobber (reg:SI T_REG))]
-  "TARGET_SH1"
+  "TARGET_SH1 && can_create_pseudo_p ()"
   "#"
-  "&& can_create_pseudo_p ()"
+  "&& 1"
   [(const_int 0)]
 {
   emit_insn (gen_clrt ());
   [(set (match_operand:SIDI 0 "arith_reg_dest")
        (abs:SIDI (match_operand:SIDI 1 "arith_reg_operand")))
    (clobber (reg:SI T_REG))]
-  "TARGET_SH1"
+  "TARGET_SH1 && can_create_pseudo_p ()"
   "#"
-  "&& can_create_pseudo_p ()"
+  "&& 1"
   [(const_int 0)]
 {
   if (<MODE>mode == SImode)
   [(set (match_operand:SIDI 0 "arith_reg_dest")
        (neg:SIDI (abs:SIDI (match_operand:SIDI 1 "arith_reg_operand"))))
    (clobber (reg:SI T_REG))]
-  "TARGET_SH1"
+  "TARGET_SH1 && can_create_pseudo_p ()"
   "#"
-  "&& can_create_pseudo_p ()"
+  "&& 1"
   [(const_int 0)]
 {
   if (<MODE>mode == SImode)
          (match_operand:DI 1 "arith_reg_operand")
          (neg:DI (match_operand:DI 2 "arith_reg_operand"))))
    (clobber (reg:SI T_REG))]
-  "TARGET_SH1"
+  "TARGET_SH1 && can_create_pseudo_p ()"
   "#"
-  "&& can_create_pseudo_p ()"
+  "&& 1"
   [(const_int 0)]
 {
   rtx_code_label *skip_neg_label = gen_label_rtx ();
                                   (const_int 8))
                        (const_int 65280))
                (match_operand:SI 2 "arith_reg_operand" "r")))]
-  "TARGET_SH1 && ! reload_in_progress && ! reload_completed"
+  "TARGET_SH1 && ! reload_in_progress && ! reload_completed && can_create_pseudo_p ()"
   "#"
-  "&& can_create_pseudo_p ()"
+  "&& 1"
   [(const_int 0)]
 {
   rtx tmp0 = gen_reg_rtx (SImode);
                                   (const_int 8))
                        (const_int 65280))
                (zero_extract:SI (match_dup 1) (const_int 8) (const_int 8))))]
-  "TARGET_SH1 && ! reload_in_progress && ! reload_completed"
+  "TARGET_SH1 && ! reload_in_progress && ! reload_completed && can_create_pseudo_p ()"
   "#"
-  "&& can_create_pseudo_p ()"
+  "&& 1"
   [(const_int 0)]
 {
   rtx tmp = gen_reg_rtx (SImode);
   [(set (match_operand:SI 0 "arith_reg_dest" "=r")
        (match_operand:SI 1 "mem_index_disp_operand" "m"))
    (clobber (reg:SI T_REG))]
-  "TARGET_SH1"
+  "TARGET_SH1 && can_create_pseudo_p ()"
   "#"
-  "&& can_create_pseudo_p ()"
+  "&& 1"
   [(set (match_dup 6) (plus:SI (match_dup 5) (match_dup 3)))
    (set (match_dup 0) (match_dup 7))]
 {
   [(set (match_operand:SI 0 "arith_reg_dest")
        (SZ_EXTEND:SI (match_operand:HI 1 "mem_index_disp_operand")))
    (clobber (reg:SI T_REG))]
-  "TARGET_SH1"
+  "TARGET_SH1 && can_create_pseudo_p ()"
   "#"
-  "&& can_create_pseudo_p ()"
+  "&& 1"
   [(const_int 0)]
 {
   rtx mem = operands[1];
   [(set (match_operand:HISI 0 "mem_index_disp_operand" "=m")
        (match_operand:HISI 1 "arith_reg_operand" "r"))
    (clobber (reg:SI T_REG))]
-  "TARGET_SH1"
+  "TARGET_SH1 && can_create_pseudo_p ()"
   "#"
-  "&& can_create_pseudo_p ()"
+  "&& 1"
   [(set (match_dup 6) (plus:SI (match_dup 5) (match_dup 3)))
    (set (match_dup 7) (match_dup 1))]
 {
                         (const_int 1))
                 (const_int 2147483647)))
    (clobber (reg:SI T_REG))]
-  "TARGET_SH1"
+  "TARGET_SH1 && can_create_pseudo_p ()"
   "#"
-  "&& can_create_pseudo_p ()"
+  "&& 1"
   [(parallel [(set (match_dup 0)
                   (plus:SI (zero_extract:SI (match_dup 1)
                                             (const_int 1) (const_int 0))
        (plus:SI (match_operand 1 "treg_set_expr")
                 (const_int 2147483647)))  ;; 0x7fffffff
    (clobber (reg:SI T_REG))]
-  "TARGET_SH1"
+  "TARGET_SH1 && can_create_pseudo_p ()"
    "#"
-   "&& can_create_pseudo_p ()"
+   "&& 1"
   [(const_int 0)]
 {
   if (negt_reg_operand (operands[1], VOIDmode))
 (define_insn_and_split "*negt_msb"
   [(set (match_operand:SI 0 "arith_reg_dest")
        (match_operand:SI 1 "negt_reg_shl31_operand"))]
-  "TARGET_SH1"
+  "TARGET_SH1 && can_create_pseudo_p ()"
   "#"
-  "&& can_create_pseudo_p ()"
+  "&& 1"
   [(const_int 0)]
 {
   rtx tmp = gen_reg_rtx (SImode);
   [(set (match_operand:SI 0 "arith_reg_dest")
        (umin:SI (match_operand:SI 1 "arith_reg_operand") (const_int 1)))
    (clobber (reg:SI T_REG))]
-  "TARGET_SH2A"
+  "TARGET_SH2A && can_create_pseudo_p ()"
   "#"
-  "&& can_create_pseudo_p ()"
+  "&& 1"
   [(const_int 0)]
 {
   emit_insn (gen_cmpeqsi_t (operands[1], const0_rtx));