------- Comment #8 from christoph dot mallon at gmx dot de 2007-02-19 16:28 ------- (In reply to comment #7) > Constant propagation propagates through the PHI in this case:
I basically wrote this in comment #4 and #6 (though I thought it was more general, see the sidenote below) > [...] > > so this would be the place where a warning could trigger. But it's likely > this will introduce more false positives (so the "may" form is only done > very late). An optimisation - which is not stricly necessary and could just be left out - removes the cause for the warning, therefore i doubt this generates false positives. Also this warning was correctly reported before GCC 4.1, why should it suddenly trigger false positives? > it's like -Wstrict-overflow -- warn about valid optimizations of undefined > code (that is here, make it "dead"). In that sense it's a dup of the > mentioned PRs (it's treated as dead code). > > So, let's make this a request for a warning for an optimization based on > the undefinedness of a value instead ;) Why should this be a request? I still think it is a regression, because all GCCs before 4.1 correctly reported this warning (which i stated in the original posting). Further I think this warning is highly valuable. I often write code where a local variable gets declared and later gets values assigned in different code paths and I want that my compiler tells me if i forgot to do so on one path. I also expanded this test case a little: int f(int x, int z) { int y; if (x == 42) y = z; return y; } The only difference is that I don't assign a constant, but another local variable to 'y'. Now the optimisation does not trigger (because it stricly operates on constants). So this is very confusing: If the code operates on constants the warning is missing (if the Phi is simple enough). On the other hand it gets shown if non-constants or Phis with multiple non-undefined values are involved. Sidenote: In the non-constant case this could also be counted as missed optimisation. If the value gets calculated in a dominating block, the Phi could also be replaced by this value. IAACC - I Am A Compiler Constructor. My student research project was about if-conversion on SSA, so I think I know a bit about this stuff in general. (; -- christoph dot mallon at gmx dot de changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|enhancement |minor http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30856