HomePhabricator

[SCEV] Fix nsw flags for GEP expressions

Authored by nikic on Mon, Nov 2, 12:40 PM.

Description

[SCEV] Fix nsw flags for GEP expressions

The SCEV code for constructing GEP expressions currently assumes
that the addition of the base and all the offsets is nsw if the GEP
is inbounds. While the addition of the offsets is indeed nsw, the
addition to the base address is not, as the base address is
interpreted as an unsigned value.

Fix the GEP expression code to not assume nsw for the base+offset
calculation. However, do assume nuw if we know that the offset is
non-negative. With this, we use the same behavior as the
construction of GEP addrecs does. (Modulo the fact that we
disregard SCEV unification, as the pre-existing FIXME points out).

Differential Revision: https://reviews.llvm.org/D90648

Details

Committed
nikicFri, Nov 13, 9:19 AM
Differential Revision
D90648: [SCEV] Fix nsw flags for GEP expressions
Parents
rGdf84941dcee5: [gn build] Port 8741a76f
Branches
Unknown
Tags
Unknown