https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70069

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2016-03-04
     Ever confirmed|0                           |1

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Funnily we have already the init-regs pass on RTL that does some of this
zero-initialization (for registers only though), but it's quite late.

>From an implementation perspective the easiest place to add the extra zero
inits
is when we still have BIND exprs around (you'd want to restrict zero-init to
user variables and do it when variables go into scope).  Probably at the same
place where we add CLOBBERs to mark EOL of locals, thus gimplification.

Btw, if you add the possibility to zero-init then maybe also allow different
init patterns (it would be 'memset'-like to cover arbitrary types).
-finit-vars[=value] where 'value' is either a byte value so we can use
memset directly or a larger value that is appropriately memcpy'ed as if
it were repeated.

Note that if you do this at -O0 you'll for sure get larger code as nothing
will optimize away the redundant zero-inits.  Note that these zero-inits
might trick other passes into doing different optimizations than if they
were not present (and not only due to removed undefinedness) - consider
the inliners (or other passes) size estimates for example or SRAs heuristics on
present reads/writes to decide on what transforms to apply.

Reply via email to