This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[4.1] Fix PR rtl-optimization/30787
- From: Eric Botcazou <ebotcazou at libertysurf dot fr>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 16 Feb 2007 21:54:15 +0100
- Subject: [4.1] Fix PR rtl-optimization/30787
This is a regression from the 3.x series of compilers present in 4.1.x on x86
and x86-64, again the old loop optimizer. When reducing the GIV associated
with y->s[i] in
for (i = 0; i < x; i++)
{
if (y)
y->s[i] += 1;
}
it hoists the initial value y->s out of the loop, thus bypassing the guard.
It's a variant of
2005-12-16 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/24899
* loop.c (strength_reduce): Don't reduce giv that is not always
computable and where add_val or mult_val can trap.
with an additional subtlety: the GIV is a DEST_ADDR instead of a DEST_REG so
it is deemed "always computable", albeit not "always executed".
Bootstrapped/regtested on x86_64-suse-linux and applied to 4.1 branch. The
change has no effect whatsoever on the 300+ preprocessed files of a C/C++/Ada
bootstrap at -O2 on x86.
2007-02-16 Eric Botcazou <ebotcazou@libertysurf.fr>
PR rtl-optimization/30787
* loop.c (strength_reduce): Don't reduce giv that is not always
executed and where add_val or mult_val can trap.
2007-02-16 Eric Botcazou <ebotcazou@libertysurf.fr>
* gcc.c-torture/compile/20070216-1.c: New test.
--
Eric Botcazou
Index: loop.c
===================================================================
--- loop.c (revision 121990)
+++ loop.c (working copy)
@@ -6493,13 +6493,13 @@ strength_reduce (struct loop *loop, int
v->ignore = 1;
bl->all_reduced = 0;
}
- else if (!v->always_computable
+ else if (! v->always_executed
&& (may_trap_or_fault_p (v->add_val)
|| may_trap_or_fault_p (v->mult_val)))
{
if (loop_dump_stream)
fprintf (loop_dump_stream,
- "giv of insn %d: not always computable.\n",
+ "giv of insn %d: not always executed.\n",
INSN_UID (v->insn));
v->ignore = 1;
bl->all_reduced = 0;
/* PR rtl-optimization/30787 */
/* Testcase by Jakub Jelinek <jakub@gcc.gnu.org> */
struct S
{
int *s;
};
void test (int x, struct S *y)
{
int i;
for (i = 0; i < x; i++)
{
if (y)
y->s[i] += 1;
}
}
int main (void)
{
test (1, (void *) 0);
return 0;
}