https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67732

            Bug ID: 67732
           Summary: [SH] Strange LRA addsi3 usage
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: olegendo at gcc dot gnu.org
                CC: kkojima at gcc dot gnu.org, vmakarov at gcc dot gnu.org
  Target Milestone: ---
            Target: sh*-*-*

In r228176 the SH addsi3 patterns have been extended to allow more relaxed
input operands.  They accept actually impossible predicates/constraints and the
impossible cases are then resolved after RA during splitting, like emitting
constant loads or fixing up register usage.  This gave some code size
improvement on the CSiBE set: 3345527 -> 3334351    -11176 / -0.334058 %

However, when LRA is used, the same patterns (and their order in sh.md) doesn't
work.  This disables the LRA specific patterns:

Index: gcc/config/sh/sh.md
===================================================================
--- gcc/config/sh/sh.md (revision 228176)
+++ gcc/config/sh/sh.md (working copy)
@@ -2129,7 +2129,7 @@
 {
   if (TARGET_SH1 && !arith_operand (operands[2], SImode))
     {
-      if (!sh_lra_p () || reg_overlap_mentioned_p (operands[0], operands[1]))
+      if (true || !sh_lra_p () || reg_overlap_mentioned_p (operands[0],
operands[1]))
        {
          emit_insn (gen_addsi3_scr (operands[0], operands[1], operands[2]));
          DONE;
@@ -2178,7 +2178,7 @@
   [(set (match_operand:SI 0 "arith_reg_dest" "=r,&u")
        (plus:SI (match_operand:SI 1 "arith_reg_operand" "%0,r")
                 (match_operand:SI 2 "arith_or_int_operand" "rI08,rn")))]
-  "TARGET_SH1 && sh_lra_p ()
+  "TARGET_SH1 && sh_lra_p () && false
    && (! reg_overlap_mentioned_p (operands[0], operands[1])
        || arith_operand (operands[2], SImode))"
   "@
@@ -2237,7 +2237,7 @@
   [(set (match_operand:SI 0 "arith_reg_dest" "=r,r")
        (plus:SI (match_operand:SI 1 "arith_reg_operand" "%0,r")
                 (match_operand:SI 2 "arith_operand" "rI08,Z")))]
-  "TARGET_SH1 && !sh_lra_p ()"
+  "TARGET_SH1"
   "@
        add     %2,%0
        #"


With this applied, compiling the CSiBE set results in:

internal compiler error: Segmentation fault
 }
 ^
0xa7a88f crash_signal
        ../../gcc-trunk2/gcc/toplev.c:353
0x91bebd restore_scratches
        ../../gcc-trunk2/gcc/lra.c:1981
0x91bebd lra(_IO_FILE*)
        ../../gcc-trunk2/gcc/lra.c:2402
0x8d2181 do_reload
        ../../gcc-trunk2/gcc/ira.c:5391
0x8d2181 execute
        ../../gcc-trunk2/gcc/ira.c:5562

I haven't checked the details though.

Reply via email to