http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56210
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |ASSIGNED Keywords| |missed-optimization Last reconfirmed| |2013-02-05 Component|middle-end |tree-optimization AssignedTo|unassigned at gcc dot |rguenth at gcc dot gnu.org |gnu.org | Ever Confirmed|0 |1 --- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> 2013-02-05 09:14:35 UTC --- We warn for MEM[(void *)";" + 3B]: f () { static char key[4] = "abc"; int _5; <bb 2>: _5 = strncmp (";", &key, 3); if (_5 == 0) goto <bb 3>; else goto <bb 4>; <bb 3>: __builtin_puts (&MEM[(void *)";" + 3B]); <bb 4>: return; which is of course in an unexecuted block (";" is not equal to "abc"). Which points to a missed folding of the strncmp, respectively of a missed promotion of 'key' to const. We are cleverly optimizing away the loop as we can see it executes at most once. CCP3 figures this out but fails to fold strncmp because ipa-reference does not figure it is constant - it seems to not handle builtin calls very well (puts makes it consider all vars are written to). Also points-to computes # PT = p_3 = ";"; # PT = nonlocal escaped p_9 = p_1 + 3; # PT = nonlocal escaped # USE = nonlocal escaped p_7 = __builtin_strchr (p_1, 59); # PT = nonlocal escaped p_8 = p_7 + 1; # PT = nonlocal escaped # p_1 = PHI <";"(2), p_8(6)> because strchr is not handled. Let me have a look.