This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/19828] New: [4.0 Regression] LIM is pulling out a pure function even though there is something which can modify global memory
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Feb 2005 19:03:30 -0000
- Subject: [Bug tree-optimization/19828] New: [4.0 Regression] LIM is pulling out a pure function even though there is something which can modify global memory
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Take the following program, it should run and work correct and not call abort but with -O1/-O2 on the
mainline we call abort because LIM pulls out the call to f of the loop but should not because f1 can
modify the global memory (and does). If I uncomment the store to the global memory in the function
containing the loop we get the correct code as LIM sees that the call to f has a VUSE and call to f1 has a
V_MAY_DEF.
int f(void) __attribute__((pure));
int lll;
int f() { return lll; }
int f1() { lll++; return lll % 2;}
int g(void)
{
int k, l;
k=0;
//lll = 0;
for(l =0;l<10;l++)
if (f1 ())
k = f();
return k;
}
void abort ();
int main(void)
{
if (g() != 9)
abort ();
}
--
Summary: [4.0 Regression] LIM is pulling out a pure function even
though there is something which can modify global memory
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P2
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pinskia at gcc dot gnu dot org
CC: dnovillo at gcc dot gnu dot org,drow at gcc dot gnu dot
org,gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19828