llvm.org GIT mirror llvm / 1021236
Per discussion with Dan G, inbounds geps *certainly* can have unsigned overflow (e.g. "gep P, -1"), and while they can have signed wrap in theoretical situations, modelling an AddRec as not having signed wrap is going enough for any case we can think of today. In the future if this isn't enough, we can revisit this. Modeling them as having NUW isn't causing any known problems either FWIW. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125410 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 9 years ago
2 changed file(s) with 16 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
27842784 HasNSW = true;
27852785 } else if (const GEPOperator *GEP =
27862786 dyn_cast(BEValueV)) {
2787 // If the increment is a GEP, then we know it won't perform an
2788 // unsigned overflow, because the address space cannot be
2787 // If the increment is a GEP, then we know it won't perform a
2788 // signed overflow, because the address space cannot be
27892789 // wrapped around.
2790 HasNUW |= GEP->isInBounds();
2790 //
2791 // NOTE: This isn't strictly true, because you could have an
2792 // object straddling the 2G address boundary in a 32-bit address
2793 // space (for example). We really want to model this as a "has
2794 // no signed/unsigned wrap" where the base pointer is treated as
2795 // unsigned and the increment is known to not have signed
2796 // wrapping.
2797 //
2798 // This is a highly theoretical concern though, and this is good
2799 // enough for all cases we know of at this point. :)
2800 //
2801 HasNSW |= GEP->isInBounds();
27912802 }
27922803
27932804 const SCEV *StartVal = getSCEV(StartValueV);
6161 for.body.i.i: ; preds = %for.body.i.i, %for.body.lr.ph.i.i
6262 %__first.addr.02.i.i = phi i32* [ %begin, %for.body.lr.ph.i.i ], [ %ptrincdec.i.i, %for.body.i.i ]
6363 ; CHECK: %__first.addr.02.i.i
64 ; CHECK-NEXT: --> {%begin,+,4}uw><%for.body.i.i>
64 ; CHECK-NEXT: --> {%begin,+,4}sw><%for.body.i.i>
6565 store i32 0, i32* %__first.addr.02.i.i, align 4
6666 %ptrincdec.i.i = getelementptr inbounds i32* %__first.addr.02.i.i, i64 1
6767 ; CHECK: %ptrincdec.i.i
68 ; CHECK-NEXT: --> {(4 + %begin),+,4}uw><%for.body.i.i>
68 ; CHECK-NEXT: --> {(4 + %begin),+,4}sw><%for.body.i.i>
6969 %cmp.i.i = icmp eq i32* %ptrincdec.i.i, %end
7070 br i1 %cmp.i.i, label %for.cond.for.end_crit_edge.i.i, label %for.body.i.i
7171