diff mbox

Fix PR rtl-optimization/42775

Message ID 201009202330.44434.ebotcazou@adacore.com
State New
Headers show

Commit Message

Eric Botcazou Sept. 20, 2010, 9:30 p.m. UTC
GCC 4.4.x miscompiles itself on the SPARC at -O1, a regression from earlier 
series.  tree-ssa-operands.c:copy_virtual_operands is miscompiled by delay 
slot scheduling, aka reorg, because of a dangling REG_EQUAL note.

cprop_hardreg turns:

(insn 287 286 288 39 pr42775.c:19479 (set (reg/v/f:SI 16 %l0 [orig:152 
dest_vdefs ] [152])
        (reg:SI 8 %o0)) 50 {*movsi_insn} (expr_list:REG_DEAD (reg:SI 8 %o0)
        (nil)))

[...]

(insn 348 347 349 48 pr42775.c:19529 (set (reg:SI 1 %g1 [orig:138 ivtmp.1158 ] 
[138])
        (reg/v/f:SI 16 %l0 [orig:152 dest_vdefs ] [152])) 50 {*movsi_insn} 
(nil))


into:

insn 348: replaced reg 16 with 8

(insn 287 286 288 39 pr42775.c:19479 (set (reg/v/f:SI 16 %l0 [orig:152 
dest_vdefs ] [152])
        (reg:SI 8 %o0)) 50 {*movsi_insn} (expr_list:REG_DEAD (reg:SI 8 %o0)
        (nil)))

[...]

(insn 348 347 349 48 pr42775.c:19529 (set (reg:SI 1 %g1 [orig:138 ivtmp.1158 ] 
[138])
        (reg/f:SI 8 %o0 [orig:152 dest_vdefs ] [152])) 50 {*movsi_insn} (nil))

so the REG_DEAD is now wrong and this fools the algorithm in resource.c.


Fixed by recomputing notes when reorg is enabled.  Bootstrapped/regtested on 
SPARC64/Linux and SPARC/Solaris, applied on mainline and 4.5/4.4 branches.


2010-09-20  Eric Botcazou  <ebotcazou@adacore.com>

	PR rtl-optimization/42775
	* cfgrtl.c (rest_of_pass_free_cfg): Recompute notes if delay slot
	scheduling is enabled.

Comments

Steven Bosscher Sept. 21, 2010, 8:43 p.m. UTC | #1
On Mon, Sep 20, 2010 at 11:30 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> 2010-09-20  Eric Botcazou  <ebotcazou@adacore.com>
>
>        PR rtl-optimization/42775
>        * cfgrtl.c (rest_of_pass_free_cfg): Recompute notes if delay slot
>        scheduling is enabled.

This is in the "egad but what else" category. Qualifies as obvious IMHO.

As far as I can tell from the reorg.c source, there are no other DF
problems that reorg needs, that have to be recomputed before free'ing
the CFG, right?

Ciao!
Steven
Eric Botcazou Sept. 22, 2010, 7:06 a.m. UTC | #2
> As far as I can tell from the reorg.c source, there are no other DF
> problems that reorg needs, that have to be recomputed before free'ing
> the CFG, right?

Yes, resource.c should be OK with LR + Notes.
diff mbox

Patch

Index: cfgrtl.c
===================================================================
--- cfgrtl.c	(revision 164451)
+++ cfgrtl.c	(working copy)
@@ -421,7 +421,10 @@  rest_of_pass_free_cfg (void)
   /* The resource.c machinery uses DF but the CFG isn't guaranteed to be
      valid at that point so it would be too late to call df_analyze.  */
   if (optimize > 0 && flag_delayed_branch)
-    df_analyze ();
+    {
+      df_note_add_problem ();
+      df_analyze ();
+    }
 #endif
 
   free_bb_for_insn ();