http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145
Bug ID: 58145 Summary: [Regression]: volatileness of write is discarded, perhaps in "lim1" related to loop optimizations Product: gcc Version: 4.9.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: hp at gcc dot gnu.org Target: cris-*-*, crisv32-*-* Created attachment 30640 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30640&action=edit Preprocessed code; compile at -O2, e.g. "cc1 -O2 y.i -o y.s" The exact version in which the bug appeared is not yet triaged: it's present on r201675 of trunk, r201652 of the 4.8 branch, r190527 of the 4.7 branch (!) but appears to not be present in r135713 of the 4.3 branch (!). The bug is that the volatileness of the dereference of the write (the assignment through a pointer to a volatile structure) in function pb_out is discarded, leaving a single write after the loop. Note also that together with the discarded-volatileness-bug there seems to be a missed-optimization-bug in that the loop is redundant; the loop awkwardly computes iterates over 0..31 and computes 1<<i but the intermediate computations aren't used; then the last value is written after the loop. Editing the code to manually inline pb_out makes no difference to the bug. The wrong code is evident already in the .expand dump on trunk (according to -da). It is not present (according to -fdump-tree-all-all) in y.i.096t.loopinit but appears present in y.i.097t.lim1. Until someone (including myself) has repeated the observation for another target, I'll set the target-specifier to cris*-* but it seems obviously generic, affecting all targets.