[Bug tree-optimization/82135] Missed constant propagation through possible unsigned wraparound, with std::align() variable pointer, constant everything else.

2021-12-12 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82135

Andrew Pinski  changed:

   What|Removed |Added

   Severity|normal  |enhancement
   Last reconfirmed|2017-09-12 00:00:00 |2021-12-12

[Bug tree-optimization/82135] Missed constant propagation through possible unsigned wraparound, with std::align() variable pointer, constant everything else.

2017-09-12 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82135

Richard Biener  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2017-09-12
 Ever confirmed|0   |1

--- Comment #3 from Richard Biener  ---
Thus confirmed.

[Bug tree-optimization/82135] Missed constant propagation through possible unsigned wraparound, with std::align() variable pointer, constant everything else.

2017-09-08 Thread peter at cordes dot ca
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82135

--- Comment #2 from Peter Cordes  ---
(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  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.

[Bug tree-optimization/82135] Missed constant propagation through possible unsigned wraparound, with std::align() variable pointer, constant everything else.

2017-09-07 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82135

--- Comment #1 from Marc Glisse  ---
This PR is a bit messy, please minimize your examples...
Looking at the dse2 dump (before reassoc messes things up):

  __intptr_2 = (const long unsigned int) voidp_9(D);
  _3 = __intptr_2 + 63;
  __aligned_4 = _3 & 18446744073709551552;
  __diff_5 = __aligned_4 - __intptr_2;
  _6 = __diff_5 + 64;
  if (_6 > 1024)

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

If aligned was not reused, we could simplify ((x+63)&-64)-x to 63&-x, but we
don't want to do it in general. Maybe we could add a very special case in VRP
(or CCP for nonzero bits)...
(we could also add if(__diff>__align)__builtin__unreachable() in  but
that's getting really specific)