This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/82135] Missed constant propagation through possible unsigned wraparound, with std::align() variable pointer, constant everything else.
- From: "glisse at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 07 Sep 2017 20:31:31 +0000
- Subject: [Bug tree-optimization/82135] Missed constant propagation through possible unsigned wraparound, with std::align() variable pointer, constant everything else.
- Auto-submitted: auto-generated
- References: <bug-82135-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82135
--- Comment #1 from Marc Glisse <glisse at gcc dot gnu.org> ---
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 <memory> but
that's getting really specific)