On Tue, Jul 19, 2016 at 04:49:26PM +0200, Bernd Schmidt wrote: > >But you need the profile to make even reasonably good decisions. > > I'm not worried about making cost decisions: as far as I'm concerned > it's perfectly fine for that. I'm worried about correctness - you can't > validly save registers inside a loop.
Of course you can. It needs to be paired with a restore; and we do that just fine. Pretty much *all* implementations in the literature do this, fwiw. > So IMO there needs to be an > additional cfg-based check that verifies whether the bb where we want to > place parts of the prologue is guaranteed to be executed at most once. That is equivalent to not doing this optimisation *at all*. Segher