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

--- Comment #2 from Peter Cordes <peter at cordes dot ca> ---
(In reply to Marc Glisse from comment #1)
> This PR is a bit messy, please minimize your examples...

Sorry, looking at it again later I could have done better.  I thought it was
somewhat relevant that this was from gcc's own header and had (weird) use-cases
that didn't optimize well, otherwise I prob. would have reduced it more in the
first place.

> IIUC, essentially, you would like gcc to realize that __diff_5 is in [0,63],
> so the condition is always false.

Yes, exactly.

> (we could also add if(__diff>__align)__builtin__unreachable() in <memory> but 
> that's getting really specific)

 I was too sleepy to figure out that was the real always-true condition to look
for.  Hence my other random __builtin__unreachable() attempts. :P

IDK how much use std::align gets, and if so whether it's common to use it in
cases where many of the inputs are constants after inlining.  It might be
interesting to look at how it optimizes with fewer of the inputs constant (like
maybe just align, or align and space).  If that __builtin__unreachable() helps
in any other cases, it might be worth considering.

Reply via email to