This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[3.3 PATCH] Fix PR optimization/12510
- From: Eric Botcazou <ebotcazou at libertysurf dot fr>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 7 Oct 2003 19:44:22 +0200
- Subject: [3.3 PATCH] Fix PR optimization/12510
Hi,
This is the ICE caused by the wrong ordering of splitting passes on x86, a
regression introduced by the following patch:
http://gcc.gnu.org/ml/gcc-patches/2003-02/msg02260.html
Basically one splitting pass is missing at -O1 on x86 between flow2 and
reg-stack. This was detected and fixed on mainline by Jakub with:
http://gcc.gnu.org/ml/gcc-patches/2003-09/msg00457.html
but it is still present on the 3.3 branch as of today.
I find Jakub's patch convoluted so I wrote my own version for the branch.
Bootstrapped/regtested on i586-redhat-linux-gnu (3.3 branch except Ada).
2003-10-07 Eric Botcazou <ebotcazou@libertysurf.fr>
PR optimization/12510
* toplev.c (rest_of_compilation) [insns_split_for_shed2]: New
automatic variable to record whether insns were split for sched2.
Split only when optimizing before flow2 when STACK_REGS is defined.
Split before reg-stack if insns were not split for sched2.
2003-10-07 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
* gcc.dg/20031007-1.c: New test.
--
Eric Botcazou
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.690.2.22
diff -u -p -r1.690.2.22 toplev.c
--- toplev.c 17 Sep 2003 07:17:09 -0000 1.690.2.22
+++ toplev.c 7 Oct 2003 09:48:33 -0000
@@ -2364,6 +2364,7 @@ rest_of_compilation (decl)
int failure = 0;
int rebuild_label_notes_after_reload;
int register_life_up_to_date;
+ int insns_split_for_shed2;
timevar_push (TV_REST_OF_COMPILATION);
@@ -3361,9 +3362,7 @@ rest_of_compilation (decl)
#endif
/* If optimizing, then go ahead and split insns now. */
-#ifndef STACK_REGS
if (optimize > 0)
-#endif
split_all_insns (0);
if (optimize)
@@ -3436,6 +3435,8 @@ rest_of_compilation (decl)
timevar_pop (TV_IFCVT2);
}
+ insns_split_for_shed2 = 0;
+
#ifdef INSN_SCHEDULING
if (optimize > 0 && flag_schedule_insns_after_reload)
{
@@ -3446,6 +3447,7 @@ rest_of_compilation (decl)
and write some more of the results to dump file. */
split_all_insns (1);
+ insns_split_for_shed2 = 1;
schedule_insns (rtl_dump_file);
@@ -3464,6 +3466,11 @@ rest_of_compilation (decl)
#ifdef STACK_REGS
timevar_push (TV_REG_STACK);
open_dump_file (DFI_stack, decl);
+
+ /* We have to split now because we won't split
+ before shorten_branches below. */
+ if (! insns_split_for_shed2)
+ split_all_insns (optimize > 0);
reg_to_stack (insns, rtl_dump_file);
/* PR optimization/12510 */
/* Origin: Lars Skovlund <lskovlun@image.dk> */
/* Reduced testcase by Volker Reichelt <reichelt@igpm.rwth-aachen.de> */
/* Verify that one splitting pass is not missing on x86 at -O1 */
/* { dg-do compile } */
/* { dg-options "-O -mcpu=i686" { target i?86-*-* x86_64-*-* } } */
extern foo(double);
void bar(double x, double y)
{
foo (x);
if (y) x = y ? 0 : 1/y;
else if (y) x = y < 1 ? 1 : y;
else x = 1/y < 1 ? 1 : x;
foo (x);
}