The following patch is for PR59340. The rationale for the patch can be found in my comment on:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59340

The patch also fixes PPC bootstrap (with LRA switched on).

The patch was committed as rev. 205541.

2013-11-29  Vladimir Makarov  <vmaka...@redhat.com>

        PR rtl-optimization/59340
        * lra.c (check_rtl): Use recog_memoized instead of
        insn_invalid_p.

        Revert
        2013-11-20  Robert Suchanek  <robert.sucha...@imgtec.com>

        * lra.c (lra): Set lra_in_progress before check_rtl call.
        * recog.c (insn_invalid_p): Add !lra_in_progress to prevent
        adding clobber regs when LRA is running.

Index: recog.c
===================================================================
--- recog.c     (revision 205540)
+++ recog.c     (working copy)
@@ -315,8 +315,7 @@ insn_invalid_p (rtx insn, bool in_group)
   int icode = recog (pat, insn,
                     (GET_CODE (pat) == SET
                      && ! reload_completed
-                      && ! reload_in_progress
-                      && ! lra_in_progress)
+                      && ! reload_in_progress)
                     ? &num_clobbers : 0);
   int is_asm = icode < 0 && asm_noperands (PATTERN (insn)) >= 0;

Index: lra.c
===================================================================
--- lra.c       (revision 205540)
+++ lra.c       (working copy)
@@ -2066,8 +2066,9 @@ check_rtl (bool final_p)
           correctly decomposed.  LRA can generate reloads for
           decomposable addresses.  The decomposition code checks the
           correctness of the addresses.  So we don't need to check
-          the addresses here.  */
-       if (insn_invalid_p (insn, false))
+          the addresses here.  Don't call insn_invalid_p here, it can
+          change the code at this stage.  */
+       if (recog_memoized (insn) < 0 && asm_noperands (PATTERN (insn)) < 0)
          fatal_insn_not_found (insn);
       }
 }
@@ -2266,14 +2267,13 @@ lra (FILE *f)

   init_insn_recog_data ();

-  /* We can not set up reload_in_progress because it prevents new
-     pseudo creation.  */
-  lra_in_progress = 1;
-
 #ifdef ENABLE_CHECKING
+  /* Some quick check on RTL generated by previous passes.  */
   check_rtl (false);
 #endif

+  lra_in_progress = 1;
+
   lra_live_range_iter = lra_coalesce_iter = 0;
   lra_constraint_iter = lra_constraint_iter_after_spill = 0;
   lra_inheritance_iter = lra_undo_inheritance_iter = 0;

Reply via email to