Summary: | bogus uninitialized warning (huge testcase) | ||
---|---|---|---|
Product: | gcc | Reporter: | Martin Reinecke <martin> |
Component: | c++ | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED WORKSFORME | ||
Severity: | enhancement | CC: | gcc-bugs, manu |
Priority: | P3 | ||
Version: | 4.4.0 | ||
Target Milestone: | --- | ||
Host: | i686-pc-linux-gnu | Target: | i686-pc-linux-gnu |
Build: | i686-pc-linux-gnu | Known to work: | |
Known to fail: | Last reconfirmed: | 2008-05-07 10:12:31 | |
Bug Depends on: | |||
Bug Blocks: | 24639 | ||
Attachments: | a (not really reduced) test case |
Description
Martin Reinecke
2008-05-07 09:33:42 UTC
Created attachment 15590 [details]
a (not really reduced) test case
This is a normal issue with the unitialized warnings. See PR 5035. Basically to get this warning correct for this case, you need conditional PHIs which we don't have currently. And I don't know of any compiler that does. Basically the code looks like: if (a) set b for(...) for(...) if (a) use b Unswitching the loops will help somewhat as then you can then jump thread. Thanks, Andrew Pinski Also you may as well manually unswitch the loops as they don't do anything except some multiplication if that bool is true. That is better to write the code as: if (a_eq_e) return; e=p[m].e; q=COLOUR8(e.r/(a.r+grayabsorb),e.g/(a.g+grayabsorb),e.b/(a.b+grayabsorb)); float64 radsq = rfacr*rfacr; float64 prefac1 = -0.5/(r*r*sigma0*sigma0); float64 prefac2 = -0.5*bfak/p[m].ro; { for (int x=minx; x<maxx; ++x) { float64 xsq=(x-posx)*(x-posx); for (int y=miny; y<maxy; ++y) { float64 dsq = (y-posy)*(y-posy) + xsq; if (dsq<radsq) { lpic[x][y].r = q.r; lpic[x][y].g = q.g; } } } } As you now have better code as the code is faster as you don't have to go through those loops at all or even calculate the inner float64s. It would be completely fine by me, if g++ simply emitted bogus warnings in a consistent way. But the syntax is still confusing, and what seems quite disconcerting to me is the fact that _both_ warnings disappear if I comment the line 37214 (lpic[x][y].g = q.g;). Is this also expected behaviour? (In reply to comment #4) > Is this also expected behavior? Most likely because SRA choses not to scalarize the aggregate. Aka the optimizators are choosing different choses based on the code. Nothing new. -- Pinski OK. Thanks for the clarification! This would be more consistent if uninitialized warnings would work in VOPs. Anyway, I think we should keep this open as an interesting testcase. Things TODO here: * Find out if we can get the "original form" of 'q.COLOUR8::r' to print something closer to the original code. * What is the difference in SSA after SRA when line 37214 is commented out? * Perhaps we should never warn about things like this. Can we mark them as artificial? If not, try setting and preserving TREE_NO_WARNING. * Does this have to do with compiler-generated EH? If so, this is a duplicate of another PR I have seen. * The attached testcase is too big for the testsuite. We would need a smaller one. Unfortunately, automatically reducing the testcase would probably lead to a bogus one. So it must be done manually or find an alternative testcase. >* Find out if we can get the "original form" of 'q.COLOUR8::r' to print
something closer to the original code.
Actually this is a good thing we print out "COLOUR8::" really, sometimes there are different r's in a class so knowing which one is being used here makes it easy to understand.
I cannot reproduce this with current GCC 4.4 Also, the testcase is too big. Actually, I am going to close it as WORKSFORME, but if you can reproduce this with a GCC later than revision 143971 (even in this huge testcase), please reopen. Thanks for the report. |