From 2ca8a3f2132ec7d46151b4553ee166c4e635fd70 Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Fri, 1 Oct 2021 16:30:44 -0700 Subject: [PATCH] [SCEV] Stop blindly propagating flags from inbound geps to SCEV nodes This fixes a violation of the wrap flag rules introduced in c4048d8f. This was also noted in the (very old) PR23527. The issue being fixed is that we assume the inbound flag on any GEP assumes that all users of *any* gep (or add) which happens to map to that SCEV would also be UB if the (other) gep overflowed. That's simply not true. In terms of the test diffs, I don't see anything seriously problematic. The lost flags are expected (given the semantic restriction on when its legal to tag the SCEV), and there are several cases where the previously inferred flags are unsound per the new semantics. The only common trend I noticed when looking at the deltas is that by not considering branch on poison as immediate UB in ValueTracking, we do miss a few cases we could reclaim. We may be able to claw some of these back with the follow ideas mentioned in PR51817. It's worth noting that most of the changes are analysis result only changes. The two transform changes are pretty minimal. In one case, we miss the opportunity to infer a nuw (correctly). In the other, we fail to fold an exit and produce a loop invariant form instead. This one is probably over-reduced as the program appears to be undefined in practice, and neither before or after exploits that. Differential Revision: https://reviews.llvm.org/D109789 --- llvm/lib/Analysis/ScalarEvolution.cpp | 22 ++++++--- .../memcheck-wrapping-pointers.ll | 4 +- .../LoopCacheAnalysis/PowerPC/stencil.ll | 4 +- llvm/test/Analysis/ScalarEvolution/load.ll | 2 +- .../max-backedge-taken-count-guard-info.ll | 2 +- .../ScalarEvolution/no-wrap-add-exprs.ll | 12 ++--- .../no-wrap-symbolic-becount.ll | 26 +++++----- llvm/test/Analysis/ScalarEvolution/nsw.ll | 48 +++++++++---------- .../test/Analysis/ScalarEvolution/ptrtoint.ll | 22 ++++----- llvm/test/Analysis/ScalarEvolution/sdiv.ll | 2 +- llvm/test/Analysis/ScalarEvolution/srem.ll | 2 +- .../IndVarSimplify/eliminate-exit-no-dl.ll | 3 +- .../X86/expander-crashes.ll | 2 +- ...ffine-loop-condition-dependent-access_2.ll | 4 +- .../test/ScopInfo/pointer-type-expressions.ll | 2 +- polly/test/ScopInfo/unsigned-division-5.ll | 4 +- 16 files changed, 83 insertions(+), 78 deletions(-) diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index ed929654967d..dacfbbd750d6 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -3608,13 +3608,21 @@ ScalarEvolution::getGEPExpr(GEPOperator *GEP, // getSCEV(Base)->getType() has the same address space as Base->getType() // because SCEV::getType() preserves the address space. Type *IntIdxTy = getEffectiveSCEVType(BaseExpr->getType()); - // FIXME(PR23527): Don't blindly transfer the inbounds flag from the GEP - // instruction to its SCEV, because the Instruction may be guarded by control - // flow and the no-overflow bits may not be valid for the expression in any - // context. This can be fixed similarly to how these flags are handled for - // adds. + const bool AssumeInBoundsFlags = [&]() { + if (!GEP->isInBounds()) + return false; + + // We'd like to propagate flags from the IR to the corresponding SCEV nodes, + // but to do that, we have to ensure that said flag is valid in the entire + // defined scope of the SCEV. + auto *GEPI = dyn_cast(GEP); + // TODO: non-instructions have global scope. We might be able to prove + // some global scope cases + return GEPI && isSCEVExprNeverPoison(GEPI); + }(); + SCEV::NoWrapFlags OffsetWrap = - GEP->isInBounds() ? SCEV::FlagNSW : SCEV::FlagAnyWrap; + AssumeInBoundsFlags ? SCEV::FlagNSW : SCEV::FlagAnyWrap; Type *CurTy = GEP->getType(); bool FirstIter = true; @@ -3660,7 +3668,7 @@ ScalarEvolution::getGEPExpr(GEPOperator *GEP, // Add the base address and the offset. We cannot use the nsw flag, as the // base address is unsigned. However, if we know that the offset is // non-negative, we can use nuw. - SCEV::NoWrapFlags BaseWrap = GEP->isInBounds() && isKnownNonNegative(Offset) + SCEV::NoWrapFlags BaseWrap = AssumeInBoundsFlags && isKnownNonNegative(Offset) ? SCEV::FlagNUW : SCEV::FlagAnyWrap; auto *GEPExpr = getAddExpr(BaseExpr, Offset, BaseWrap); assert(BaseExpr->getType() == GEPExpr->getType() && diff --git a/llvm/test/Analysis/LoopAccessAnalysis/memcheck-wrapping-pointers.ll b/llvm/test/Analysis/LoopAccessAnalysis/memcheck-wrapping-pointers.ll index d6f7dbb138f5..cc14c604c0f1 100644 --- a/llvm/test/Analysis/LoopAccessAnalysis/memcheck-wrapping-pointers.ll +++ b/llvm/test/Analysis/LoopAccessAnalysis/memcheck-wrapping-pointers.ll @@ -45,10 +45,10 @@ target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" ; CHECK-NEXT: {0,+,1}<%for.body> Added Flags: ; CHECK: Expressions re-written: ; CHECK-NEXT: [PSE] %arrayidx = getelementptr inbounds i32, i32* %a, i64 %idxprom: -; CHECK-NEXT: ((4 * (zext i32 {1,+,1}<%for.body> to i64)) + %a) +; CHECK-NEXT: ((4 * (zext i32 {1,+,1}<%for.body> to i64)) + %a) ; CHECK-NEXT: --> {(4 + %a),+,4}<%for.body> ; CHECK-NEXT: [PSE] %arrayidx4 = getelementptr inbounds i32, i32* %b, i64 %conv11: -; CHECK-NEXT: ((4 * (zext i32 {0,+,1}<%for.body> to i64)) + %b) +; CHECK-NEXT: ((4 * (zext i32 {0,+,1}<%for.body> to i64)) + %b) ; CHECK-NEXT: --> {%b,+,4}<%for.body> define void @test1(i64 %x, i32* %a, i32* %b) { entry: diff --git a/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/stencil.ll b/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/stencil.ll index 1f1515435e1a..821513199546 100644 --- a/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/stencil.ll +++ b/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/stencil.ll @@ -11,8 +11,8 @@ target triple = "powerpc64le-unknown-linux-gnu" ; } ; } -; CHECK-DAG: Loop 'for.i' has cost = 20600 -; CHECK-DAG: Loop 'for.j' has cost = 800 +; CHECK-DAG: Loop 'for.i' has cost = 20300 +; CHECK-DAG: Loop 'for.j' has cost = 700 define void @foo(i64 %n, i64 %m, i32* %A, i32* %B, i32* %C) { entry: diff --git a/llvm/test/Analysis/ScalarEvolution/load.ll b/llvm/test/Analysis/ScalarEvolution/load.ll index e95a093b2a8b..c0d671342af7 100644 --- a/llvm/test/Analysis/ScalarEvolution/load.ll +++ b/llvm/test/Analysis/ScalarEvolution/load.ll @@ -73,7 +73,7 @@ define i32 @test2() nounwind uwtable readonly { ; CHECK-NEXT: %n.01 = phi %struct.ListNode* [ bitcast ({ %struct.ListNode*, i32, [4 x i8] }* @node5 to %struct.ListNode*), %entry ], [ %1, %for.body ] ; CHECK-NEXT: --> %n.01 U: full-set S: full-set Exits: @node1 LoopDispositions: { %for.body: Variant } ; CHECK-NEXT: %i = getelementptr inbounds %struct.ListNode, %struct.ListNode* %n.01, i64 0, i32 1 -; CHECK-NEXT: --> (4 + %n.01) U: [4,0) S: [4,0) Exits: (4 + @node1) LoopDispositions: { %for.body: Variant } +; CHECK-NEXT: --> (4 + %n.01) U: full-set S: full-set Exits: (4 + @node1) LoopDispositions: { %for.body: Variant } ; CHECK-NEXT: %0 = load i32, i32* %i, align 4 ; CHECK-NEXT: --> %0 U: full-set S: full-set Exits: 0 LoopDispositions: { %for.body: Variant } ; CHECK-NEXT: %add = add nsw i32 %0, %sum.02 diff --git a/llvm/test/Analysis/ScalarEvolution/max-backedge-taken-count-guard-info.ll b/llvm/test/Analysis/ScalarEvolution/max-backedge-taken-count-guard-info.ll index a8e31b681f43..a3dcc174acbb 100644 --- a/llvm/test/Analysis/ScalarEvolution/max-backedge-taken-count-guard-info.ll +++ b/llvm/test/Analysis/ScalarEvolution/max-backedge-taken-count-guard-info.ll @@ -911,7 +911,7 @@ define void @crash(i8* %ptr) { ; CHECK-NEXT: %lastout.2271 = phi i8* [ %incdec.ptr126, %while.body125 ], [ %ptr, %while.end117 ] ; CHECK-NEXT: --> {%ptr,+,1}<%while.body125> U: full-set S: full-set Exits: {(-2 + (-1 * (ptrtoint i8* %ptr to i64)) + %ptr),+,-1}<%while.cond111> LoopDispositions: { %while.body125: Computable } ; CHECK-NEXT: %incdec.ptr126 = getelementptr inbounds i8, i8* %lastout.2271, i64 1 -; CHECK-NEXT: --> {(1 + %ptr),+,1}<%while.body125> U: [1,0) S: [1,0) Exits: {(-1 + (-1 * (ptrtoint i8* %ptr to i64)) + %ptr),+,-1}<%while.cond111> LoopDispositions: { %while.body125: Computable } +; CHECK-NEXT: --> {(1 + %ptr),+,1}<%while.body125> U: full-set S: full-set Exits: {(-1 + (-1 * (ptrtoint i8* %ptr to i64)) + %ptr),+,-1}<%while.cond111> LoopDispositions: { %while.body125: Computable } ; CHECK-NEXT: Determining loop execution counts for: @crash ; CHECK-NEXT: Loop %while.body125: backedge-taken count is {(-2 + (-1 * (ptrtoint i8* %ptr to i64))),+,-1}<%while.cond111> ; CHECK-NEXT: Loop %while.body125: max backedge-taken count is -2 diff --git a/llvm/test/Analysis/ScalarEvolution/no-wrap-add-exprs.ll b/llvm/test/Analysis/ScalarEvolution/no-wrap-add-exprs.ll index 6b24a641c17b..431d999c8cf3 100644 --- a/llvm/test/Analysis/ScalarEvolution/no-wrap-add-exprs.ll +++ b/llvm/test/Analysis/ScalarEvolution/no-wrap-add-exprs.ll @@ -209,11 +209,11 @@ define void @f3(i8* %x_addr, i8* %y_addr, i32* %tmp_addr) { ; CHECK-NEXT: %sunkaddr3 = mul i64 %add4.zext, 4 ; CHECK-NEXT: --> (4 * (zext i32 (4 + (4 * (%tmp /u 4))) to i64)) U: [0,17179869169) S: [0,17179869181) ; CHECK-NEXT: %sunkaddr4 = getelementptr inbounds i8, i8* bitcast ({ %union, [2000 x i8] }* @tmp_addr to i8*), i64 %sunkaddr3 -; CHECK-NEXT: --> ((4 * (zext i32 (4 + (4 * (%tmp /u 4))) to i64)) + @tmp_addr) U: [0,-3) S: [-9223372036854775808,9223372036854775805) +; CHECK-NEXT: --> ((4 * (zext i32 (4 + (4 * (%tmp /u 4))) to i64)) + @tmp_addr) U: [0,-3) S: [-9223372036854775808,9223372036854775805) ; CHECK-NEXT: %sunkaddr5 = getelementptr inbounds i8, i8* %sunkaddr4, i64 4096 -; CHECK-NEXT: --> (4096 + (4 * (zext i32 (4 + (4 * (%tmp /u 4))) to i64)) + @tmp_addr) U: [4096,-3) S: [-9223372036854775808,9223372036854775805) +; CHECK-NEXT: --> (4096 + (4 * (zext i32 (4 + (4 * (%tmp /u 4))) to i64)) + @tmp_addr) U: [0,-3) S: [-9223372036854775808,9223372036854775805) ; CHECK-NEXT: %addr4.cast = bitcast i8* %sunkaddr5 to i32* -; CHECK-NEXT: --> (4096 + (4 * (zext i32 (4 + (4 * (%tmp /u 4))) to i64)) + @tmp_addr) U: [4096,-3) S: [-9223372036854775808,9223372036854775805) +; CHECK-NEXT: --> (4096 + (4 * (zext i32 (4 + (4 * (%tmp /u 4))) to i64)) + @tmp_addr) U: [0,-3) S: [-9223372036854775808,9223372036854775805) ; CHECK-NEXT: %addr4.incr = getelementptr i32, i32* %addr4.cast, i64 1 ; CHECK-NEXT: --> (4100 + (4 * (zext i32 (4 + (4 * (%tmp /u 4))) to i64)) + @tmp_addr) U: [0,-3) S: [-9223372036854775808,9223372036854775805) ; CHECK-NEXT: %add5 = add i32 %mul, 5 @@ -223,11 +223,11 @@ define void @f3(i8* %x_addr, i8* %y_addr, i32* %tmp_addr) { ; CHECK-NEXT: %sunkaddr0 = mul i64 %add5.zext, 4 ; CHECK-NEXT: --> (4 + (4 * (zext i32 (4 + (4 * (%tmp /u 4))) to i64))) U: [4,17179869173) S: [4,17179869185) ; CHECK-NEXT: %sunkaddr1 = getelementptr inbounds i8, i8* bitcast ({ %union, [2000 x i8] }* @tmp_addr to i8*), i64 %sunkaddr0 -; CHECK-NEXT: --> (4 + (4 * (zext i32 (4 + (4 * (%tmp /u 4))) to i64)) + @tmp_addr) U: [4,-3) S: [-9223372036854775808,9223372036854775805) +; CHECK-NEXT: --> (4 + (4 * (zext i32 (4 + (4 * (%tmp /u 4))) to i64)) + @tmp_addr) U: [0,-3) S: [-9223372036854775808,9223372036854775805) ; CHECK-NEXT: %sunkaddr2 = getelementptr inbounds i8, i8* %sunkaddr1, i64 4096 -; CHECK-NEXT: --> (4100 + (4 * (zext i32 (4 + (4 * (%tmp /u 4))) to i64)) + @tmp_addr) U: [0,-3) S: [-9223372036854775808,9223372036854775805) +; CHECK-NEXT: --> (4100 + (4 * (zext i32 (4 + (4 * (%tmp /u 4))) to i64)) + @tmp_addr) U: [0,-3) S: [-9223372036854775808,9223372036854775805) ; CHECK-NEXT: %addr5.cast = bitcast i8* %sunkaddr2 to i32* -; CHECK-NEXT: --> (4100 + (4 * (zext i32 (4 + (4 * (%tmp /u 4))) to i64)) + @tmp_addr) U: [0,-3) S: [-9223372036854775808,9223372036854775805) +; CHECK-NEXT: --> (4100 + (4 * (zext i32 (4 + (4 * (%tmp /u 4))) to i64)) + @tmp_addr) U: [0,-3) S: [-9223372036854775808,9223372036854775805) ; CHECK-NEXT: Determining loop execution counts for: @f3 ; entry: diff --git a/llvm/test/Analysis/ScalarEvolution/no-wrap-symbolic-becount.ll b/llvm/test/Analysis/ScalarEvolution/no-wrap-symbolic-becount.ll index 7a6226e9f012..5cd7f6d22cf9 100644 --- a/llvm/test/Analysis/ScalarEvolution/no-wrap-symbolic-becount.ll +++ b/llvm/test/Analysis/ScalarEvolution/no-wrap-symbolic-becount.ll @@ -95,17 +95,15 @@ define void @pointer_iv_nowrap(i8* %startptr, i8* %endptr) local_unnamed_addr { ; CHECK-LABEL: 'pointer_iv_nowrap' ; CHECK-NEXT: Classifying expressions for: @pointer_iv_nowrap ; CHECK-NEXT: %init = getelementptr inbounds i8, i8* %startptr, i64 2000 -; CHECK-NEXT: --> (2000 + %startptr) U: [2000,0) S: [2000,0) +; CHECK-NEXT: --> (2000 + %startptr) U: full-set S: full-set ; CHECK-NEXT: %iv = phi i8* [ %init, %entry ], [ %iv.next, %loop ] -; CHECK-NEXT: --> {(2000 + %startptr),+,1}<%loop> U: [2000,0) S: [2000,0) Exits: ((-1 * (ptrtoint i8* %startptr to i64)) + ((2000 + (ptrtoint i8* %startptr to i64)) umax (ptrtoint i8* %endptr to i64)) + %startptr) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: --> {(2000 + %startptr),+,1}<%loop> U: full-set S: full-set Exits: <> LoopDispositions: { %loop: Computable } ; CHECK-NEXT: %iv.next = getelementptr inbounds i8, i8* %iv, i64 1 -; CHECK-NEXT: --> {(2001 + %startptr),+,1}<%loop> U: [2001,0) S: [2001,0) Exits: (1 + (-1 * (ptrtoint i8* %startptr to i64)) + ((2000 + (ptrtoint i8* %startptr to i64)) umax (ptrtoint i8* %endptr to i64)) + %startptr) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: --> {(2001 + %startptr),+,1}<%loop> U: full-set S: full-set Exits: <> LoopDispositions: { %loop: Computable } ; CHECK-NEXT: Determining loop execution counts for: @pointer_iv_nowrap -; CHECK-NEXT: Loop %loop: backedge-taken count is (-2000 + (-1 * (ptrtoint i8* %startptr to i64)) + ((2000 + (ptrtoint i8* %startptr to i64)) umax (ptrtoint i8* %endptr to i64))) -; CHECK-NEXT: Loop %loop: max backedge-taken count is -2001 -; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (-2000 + (-1 * (ptrtoint i8* %startptr to i64)) + ((2000 + (ptrtoint i8* %startptr to i64)) umax (ptrtoint i8* %endptr to i64))) -; CHECK-NEXT: Predicates: -; CHECK: Loop %loop: Trip multiple is 1 +; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count. +; CHECK-NEXT: Loop %loop: Unpredictable max backedge-taken count. +; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count. ; entry: %init = getelementptr inbounds i8, i8* %startptr, i64 2000 @@ -125,15 +123,15 @@ define void @pointer_iv_nowrap_guard(i32* %startptr, i32* %endptr) local_unnamed ; CHECK-LABEL: 'pointer_iv_nowrap_guard' ; CHECK-NEXT: Classifying expressions for: @pointer_iv_nowrap_guard ; CHECK-NEXT: %init = getelementptr inbounds i32, i32* %startptr, i64 2000 -; CHECK-NEXT: --> (8000 + %startptr) U: [8000,0) S: [8000,0) +; CHECK-NEXT: --> (8000 + %startptr) U: full-set S: full-set ; CHECK-NEXT: %iv = phi i32* [ %init, %entry ], [ %iv.next, %loop ] -; CHECK-NEXT: --> {(8000 + %startptr),+,4}<%loop> U: [8000,0) S: [8000,0) Exits: (8000 + (4 * ((-8001 + (-1 * (ptrtoint i32* %startptr to i64)) + (ptrtoint i32* %endptr to i64)) /u 4)) + %startptr) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: --> {(8000 + %startptr),+,4}<%loop> U: full-set S: full-set Exits: (8000 + (4 * ((-8001 + (-1 * (ptrtoint i32* %startptr to i64)) + ((8004 + (ptrtoint i32* %startptr to i64)) umax (ptrtoint i32* %endptr to i64))) /u 4)) + %startptr) LoopDispositions: { %loop: Computable } ; CHECK-NEXT: %iv.next = getelementptr inbounds i32, i32* %iv, i64 1 -; CHECK-NEXT: --> {(8004 + %startptr),+,4}<%loop> U: [8004,0) S: [8004,0) Exits: (8004 + (4 * ((-8001 + (-1 * (ptrtoint i32* %startptr to i64)) + (ptrtoint i32* %endptr to i64)) /u 4)) + %startptr) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: --> {(8004 + %startptr),+,4}<%loop> U: full-set S: full-set Exits: (8004 + (4 * ((-8001 + (-1 * (ptrtoint i32* %startptr to i64)) + ((8004 + (ptrtoint i32* %startptr to i64)) umax (ptrtoint i32* %endptr to i64))) /u 4)) + %startptr) LoopDispositions: { %loop: Computable } ; CHECK-NEXT: Determining loop execution counts for: @pointer_iv_nowrap_guard -; CHECK-NEXT: Loop %loop: backedge-taken count is ((-8001 + (-1 * (ptrtoint i32* %startptr to i64)) + (ptrtoint i32* %endptr to i64)) /u 4) -; CHECK-NEXT: Loop %loop: max backedge-taken count is 4611686018427385902 -; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is ((-8001 + (-1 * (ptrtoint i32* %startptr to i64)) + (ptrtoint i32* %endptr to i64)) /u 4) +; CHECK-NEXT: Loop %loop: backedge-taken count is ((-8001 + (-1 * (ptrtoint i32* %startptr to i64)) + ((8004 + (ptrtoint i32* %startptr to i64)) umax (ptrtoint i32* %endptr to i64))) /u 4) +; CHECK-NEXT: Loop %loop: max backedge-taken count is 4611686018427387903 +; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is ((-8001 + (-1 * (ptrtoint i32* %startptr to i64)) + ((8004 + (ptrtoint i32* %startptr to i64)) umax (ptrtoint i32* %endptr to i64))) /u 4) ; CHECK-NEXT: Predicates: ; CHECK: Loop %loop: Trip multiple is 1 ; diff --git a/llvm/test/Analysis/ScalarEvolution/nsw.ll b/llvm/test/Analysis/ScalarEvolution/nsw.ll index bdcddbeffd3e..99bd34a2a9ea 100644 --- a/llvm/test/Analysis/ScalarEvolution/nsw.ll +++ b/llvm/test/Analysis/ScalarEvolution/nsw.ll @@ -25,7 +25,7 @@ define void @test1(double* %p) nounwind { ; CHECK-NEXT: %phitmp = sext i32 %tmp8 to i64 ; CHECK-NEXT: --> {1,+,1}<%bb> U: [1,-9223372036854775808) S: [1,-9223372036854775808) Exits: <> LoopDispositions: { %bb: Computable } ; CHECK-NEXT: %tmp9 = getelementptr inbounds double, double* %p, i64 %phitmp -; CHECK-NEXT: --> {(8 + %p),+,8}<%bb> U: [8,0) S: [8,0) Exits: <> LoopDispositions: { %bb: Computable } +; CHECK-NEXT: --> {(8 + %p),+,8}<%bb> U: full-set S: full-set Exits: <> LoopDispositions: { %bb: Computable } ; CHECK-NEXT: Determining loop execution counts for: @test1 ; CHECK-NEXT: Loop %bb: Unpredictable backedge-taken count. ; CHECK-NEXT: Loop %bb: Unpredictable max backedge-taken count. @@ -73,7 +73,7 @@ define void @test2(i32* %begin, i32* %end) ssp { ; CHECK-NEXT: %__first.addr.02.i.i = phi i32* [ %begin, %for.body.lr.ph.i.i ], [ %ptrincdec.i.i, %for.body.i.i ] ; CHECK-NEXT: --> {%begin,+,4}<%for.body.i.i> U: full-set S: full-set Exits: ((4 * ((-4 + (-1 * (ptrtoint i32* %begin to i64)) + (ptrtoint i32* %end to i64)) /u 4)) + %begin) LoopDispositions: { %for.body.i.i: Computable } ; CHECK-NEXT: %ptrincdec.i.i = getelementptr inbounds i32, i32* %__first.addr.02.i.i, i64 1 -; CHECK-NEXT: --> {(4 + %begin),+,4}<%for.body.i.i> U: [4,0) S: [4,0) Exits: (4 + (4 * ((-4 + (-1 * (ptrtoint i32* %begin to i64)) + (ptrtoint i32* %end to i64)) /u 4)) + %begin) LoopDispositions: { %for.body.i.i: Computable } +; CHECK-NEXT: --> {(4 + %begin),+,4}<%for.body.i.i> U: full-set S: full-set Exits: (4 + (4 * ((-4 + (-1 * (ptrtoint i32* %begin to i64)) + (ptrtoint i32* %end to i64)) /u 4)) + %begin) LoopDispositions: { %for.body.i.i: Computable } ; CHECK-NEXT: Determining loop execution counts for: @test2 ; CHECK-NEXT: Loop %for.body.i.i: backedge-taken count is ((-4 + (-1 * (ptrtoint i32* %begin to i64)) + (ptrtoint i32* %end to i64)) /u 4) ; CHECK-NEXT: Loop %for.body.i.i: max backedge-taken count is 4611686018427387903 @@ -107,19 +107,17 @@ define void @test3(i32* %begin, i32* %end) nounwind ssp { ; CHECK-LABEL: 'test3' ; CHECK-NEXT: Classifying expressions for: @test3 ; CHECK-NEXT: %indvar.i.i = phi i64 [ %tmp, %for.body.i.i ], [ 0, %entry ] -; CHECK-NEXT: --> {0,+,1}<%for.body.i.i> U: [0,4611686018427387904) S: [0,4611686018427387904) Exits: ((-4 + (-1 * (ptrtoint i32* %begin to i64)) + (ptrtoint i32* %end to i64)) /u 4) LoopDispositions: { %for.body.i.i: Computable } +; CHECK-NEXT: --> {0,+,1}<%for.body.i.i> U: [0,-9223372036854775808) S: [0,-9223372036854775808) Exits: <> LoopDispositions: { %for.body.i.i: Computable } ; CHECK-NEXT: %tmp = add nsw i64 %indvar.i.i, 1 -; CHECK-NEXT: --> {1,+,1}<%for.body.i.i> U: [1,4611686018427387905) S: [1,4611686018427387905) Exits: (1 + ((-4 + (-1 * (ptrtoint i32* %begin to i64)) + (ptrtoint i32* %end to i64)) /u 4)) LoopDispositions: { %for.body.i.i: Computable } +; CHECK-NEXT: --> {1,+,1}<%for.body.i.i> U: [1,-9223372036854775808) S: [1,-9223372036854775808) Exits: <> LoopDispositions: { %for.body.i.i: Computable } ; CHECK-NEXT: %ptrincdec.i.i = getelementptr inbounds i32, i32* %begin, i64 %tmp -; CHECK-NEXT: --> {(4 + %begin),+,4}<%for.body.i.i> U: [4,0) S: [4,0) Exits: (4 + (4 * ((-4 + (-1 * (ptrtoint i32* %begin to i64)) + (ptrtoint i32* %end to i64)) /u 4)) + %begin) LoopDispositions: { %for.body.i.i: Computable } +; CHECK-NEXT: --> {(4 + %begin),+,4}<%for.body.i.i> U: full-set S: full-set Exits: <> LoopDispositions: { %for.body.i.i: Computable } ; CHECK-NEXT: %__first.addr.08.i.i = getelementptr inbounds i32, i32* %begin, i64 %indvar.i.i -; CHECK-NEXT: --> {%begin,+,4}<%for.body.i.i> U: full-set S: full-set Exits: ((4 * ((-4 + (-1 * (ptrtoint i32* %begin to i64)) + (ptrtoint i32* %end to i64)) /u 4)) + %begin) LoopDispositions: { %for.body.i.i: Computable } +; CHECK-NEXT: --> {%begin,+,4}<%for.body.i.i> U: full-set S: full-set Exits: <> LoopDispositions: { %for.body.i.i: Computable } ; CHECK-NEXT: Determining loop execution counts for: @test3 -; CHECK-NEXT: Loop %for.body.i.i: backedge-taken count is ((-4 + (-1 * (ptrtoint i32* %begin to i64)) + (ptrtoint i32* %end to i64)) /u 4) -; CHECK-NEXT: Loop %for.body.i.i: max backedge-taken count is 4611686018427387903 -; CHECK-NEXT: Loop %for.body.i.i: Predicated backedge-taken count is ((-4 + (-1 * (ptrtoint i32* %begin to i64)) + (ptrtoint i32* %end to i64)) /u 4) -; CHECK-NEXT: Predicates: -; CHECK: Loop %for.body.i.i: Trip multiple is 1 +; CHECK-NEXT: Loop %for.body.i.i: Unpredictable backedge-taken count. +; CHECK-NEXT: Loop %for.body.i.i: Unpredictable max backedge-taken count. +; CHECK-NEXT: Loop %for.body.i.i: Unpredictable predicated backedge-taken count. ; entry: %cmp7.i.i = icmp eq i32* %begin, %end @@ -167,21 +165,21 @@ define i32 @PR12375(i32* readnone %arg) { ; CHECK-LABEL: 'PR12375' ; CHECK-NEXT: Classifying expressions for: @PR12375 ; CHECK-NEXT: %tmp = getelementptr inbounds i32, i32* %arg, i64 2 -; CHECK-NEXT: --> (8 + %arg) U: [8,0) S: [8,0) +; CHECK-NEXT: --> (8 + %arg) U: full-set S: full-set ; CHECK-NEXT: %tmp2 = phi i32* [ %arg, %bb ], [ %tmp5, %bb1 ] -; CHECK-NEXT: --> {%arg,+,4}<%bb1> U: full-set S: full-set Exits: (4 + %arg) LoopDispositions: { %bb1: Computable } +; CHECK-NEXT: --> {%arg,+,4}<%bb1> U: full-set S: full-set Exits: ((4 * ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (8 + (ptrtoint i32* %arg to i64)))) /u 4)) + %arg) LoopDispositions: { %bb1: Computable } ; CHECK-NEXT: %tmp3 = phi i32 [ 0, %bb ], [ %tmp4, %bb1 ] -; CHECK-NEXT: --> {0,+,1}<%bb1> U: [0,-2147483648) S: [0,-2147483648) Exits: 1 LoopDispositions: { %bb1: Computable } +; CHECK-NEXT: --> {0,+,1}<%bb1> U: [0,-2147483648) S: [0,-2147483648) Exits: (trunc i64 ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (8 + (ptrtoint i32* %arg to i64)))) /u 4) to i32) LoopDispositions: { %bb1: Computable } ; CHECK-NEXT: %tmp4 = add nsw i32 %tmp3, 1 -; CHECK-NEXT: --> {1,+,1}<%bb1> U: [1,0) S: [1,0) Exits: 2 LoopDispositions: { %bb1: Computable } +; CHECK-NEXT: --> {1,+,1}<%bb1> U: [1,0) S: [1,0) Exits: (1 + (trunc i64 ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (8 + (ptrtoint i32* %arg to i64)))) /u 4) to i32)) LoopDispositions: { %bb1: Computable } ; CHECK-NEXT: %tmp5 = getelementptr inbounds i32, i32* %tmp2, i64 1 -; CHECK-NEXT: --> {(4 + %arg),+,4}<%bb1> U: [4,0) S: [4,0) Exits: (8 + %arg) LoopDispositions: { %bb1: Computable } +; CHECK-NEXT: --> {(4 + %arg),+,4}<%bb1> U: full-set S: full-set Exits: (4 + (4 * ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (8 + (ptrtoint i32* %arg to i64)))) /u 4)) + %arg) LoopDispositions: { %bb1: Computable } ; CHECK-NEXT: Determining loop execution counts for: @PR12375 -; CHECK-NEXT: Loop %bb1: backedge-taken count is 1 -; CHECK-NEXT: Loop %bb1: max backedge-taken count is 1 -; CHECK-NEXT: Loop %bb1: Predicated backedge-taken count is 1 +; CHECK-NEXT: Loop %bb1: backedge-taken count is ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (8 + (ptrtoint i32* %arg to i64)))) /u 4) +; CHECK-NEXT: Loop %bb1: max backedge-taken count is 1, actual taken count either this or zero. +; CHECK-NEXT: Loop %bb1: Predicated backedge-taken count is ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (8 + (ptrtoint i32* %arg to i64)))) /u 4) ; CHECK-NEXT: Predicates: -; CHECK: Loop %bb1: Trip multiple is 2 +; CHECK: Loop %bb1: Trip multiple is 1 ; bb: %tmp = getelementptr inbounds i32, i32* %arg, i64 2 @@ -203,13 +201,13 @@ define void @PR12376(i32* nocapture %arg, i32* nocapture %arg1) { ; CHECK-LABEL: 'PR12376' ; CHECK-NEXT: Classifying expressions for: @PR12376 ; CHECK-NEXT: %tmp = phi i32* [ %arg, %bb ], [ %tmp4, %bb2 ] -; CHECK-NEXT: --> {%arg,+,4}<%bb2> U: full-set S: full-set Exits: ((4 * ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (ptrtoint i32* %arg1 to i64))) /u 4)) + %arg) LoopDispositions: { %bb2: Computable } +; CHECK-NEXT: --> {%arg,+,4}<%bb2> U: full-set S: full-set Exits: ((4 * ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (ptrtoint i32* %arg1 to i64))) /u 4)) + %arg) LoopDispositions: { %bb2: Computable } ; CHECK-NEXT: %tmp4 = getelementptr inbounds i32, i32* %tmp, i64 1 -; CHECK-NEXT: --> {(4 + %arg),+,4}<%bb2> U: [4,0) S: [4,0) Exits: (4 + (4 * ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (ptrtoint i32* %arg1 to i64))) /u 4)) + %arg) LoopDispositions: { %bb2: Computable } +; CHECK-NEXT: --> {(4 + %arg),+,4}<%bb2> U: full-set S: full-set Exits: (4 + (4 * ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (ptrtoint i32* %arg1 to i64))) /u 4)) + %arg) LoopDispositions: { %bb2: Computable } ; CHECK-NEXT: Determining loop execution counts for: @PR12376 -; CHECK-NEXT: Loop %bb2: backedge-taken count is ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (ptrtoint i32* %arg1 to i64))) /u 4) -; CHECK-NEXT: Loop %bb2: max backedge-taken count is 4611686018427387902 -; CHECK-NEXT: Loop %bb2: Predicated backedge-taken count is ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (ptrtoint i32* %arg1 to i64))) /u 4) +; CHECK-NEXT: Loop %bb2: backedge-taken count is ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (ptrtoint i32* %arg1 to i64))) /u 4) +; CHECK-NEXT: Loop %bb2: max backedge-taken count is 4611686018427387903 +; CHECK-NEXT: Loop %bb2: Predicated backedge-taken count is ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (ptrtoint i32* %arg1 to i64))) /u 4) ; CHECK-NEXT: Predicates: ; CHECK: Loop %bb2: Trip multiple is 1 ; diff --git a/llvm/test/Analysis/ScalarEvolution/ptrtoint.ll b/llvm/test/Analysis/ScalarEvolution/ptrtoint.ll index 06a39ebef531..93d8782f373e 100644 --- a/llvm/test/Analysis/ScalarEvolution/ptrtoint.ll +++ b/llvm/test/Analysis/ScalarEvolution/ptrtoint.ll @@ -192,17 +192,17 @@ define void @ptrtoint_of_gep(i8* %in, i64* %out0) { ; X64-LABEL: 'ptrtoint_of_gep' ; X64-NEXT: Classifying expressions for: @ptrtoint_of_gep ; X64-NEXT: %in_adj = getelementptr inbounds i8, i8* %in, i64 42 -; X64-NEXT: --> (42 + %in) U: [42,0) S: [42,0) +; X64-NEXT: --> (42 + %in) U: full-set S: full-set ; X64-NEXT: %p0 = ptrtoint i8* %in_adj to i64 -; X64-NEXT: --> (42 + (ptrtoint i8* %in to i64)) U: [42,0) S: [42,0) +; X64-NEXT: --> (42 + (ptrtoint i8* %in to i64)) U: full-set S: full-set ; X64-NEXT: Determining loop execution counts for: @ptrtoint_of_gep ; ; X32-LABEL: 'ptrtoint_of_gep' ; X32-NEXT: Classifying expressions for: @ptrtoint_of_gep ; X32-NEXT: %in_adj = getelementptr inbounds i8, i8* %in, i64 42 -; X32-NEXT: --> (42 + %in) U: [42,0) S: [42,0) +; X32-NEXT: --> (42 + %in) U: full-set S: full-set ; X32-NEXT: %p0 = ptrtoint i8* %in_adj to i64 -; X32-NEXT: --> (42 + (zext i32 (ptrtoint i8* %in to i32) to i64)) U: [42,4294967338) S: [42,4294967338) +; X32-NEXT: --> (zext i32 (42 + (ptrtoint i8* %in to i32)) to i64) U: [0,4294967296) S: [0,4294967296) ; X32-NEXT: Determining loop execution counts for: @ptrtoint_of_gep ; %in_adj = getelementptr inbounds i8, i8* %in, i64 42 @@ -222,9 +222,9 @@ define void @ptrtoint_of_addrec(i32* %in, i32 %count) { ; X64-NEXT: %i6 = phi i64 [ 0, %entry ], [ %i9, %loop ] ; X64-NEXT: --> {0,+,1}<%loop> U: [0,-9223372036854775808) S: [0,-9223372036854775808) Exits: (-1 + (zext i32 %count to i64)) LoopDispositions: { %loop: Computable } ; X64-NEXT: %i7 = getelementptr inbounds i32, i32* %in, i64 %i6 -; X64-NEXT: --> {%in,+,4}<%loop> U: full-set S: full-set Exits: (-4 + (4 * (zext i32 %count to i64)) + %in) LoopDispositions: { %loop: Computable } +; X64-NEXT: --> {%in,+,4}<%loop> U: full-set S: full-set Exits: (-4 + (4 * (zext i32 %count to i64)) + %in) LoopDispositions: { %loop: Computable } ; X64-NEXT: %i8 = ptrtoint i32* %i7 to i64 -; X64-NEXT: --> {(ptrtoint i32* %in to i64),+,4}<%loop> U: full-set S: full-set Exits: (-4 + (4 * (zext i32 %count to i64)) + (ptrtoint i32* %in to i64)) LoopDispositions: { %loop: Computable } +; X64-NEXT: --> {(ptrtoint i32* %in to i64),+,4}<%loop> U: full-set S: full-set Exits: (-4 + (4 * (zext i32 %count to i64)) + (ptrtoint i32* %in to i64)) LoopDispositions: { %loop: Computable } ; X64-NEXT: %i9 = add nuw nsw i64 %i6, 1 ; X64-NEXT: --> {1,+,1}<%loop> U: [1,0) S: [1,0) Exits: (zext i32 %count to i64) LoopDispositions: { %loop: Computable } ; X64-NEXT: Determining loop execution counts for: @ptrtoint_of_addrec @@ -392,7 +392,7 @@ define void @pr46786_c26_char(i8* %arg, i8* %arg1, i8* %arg2) { ; X64-NEXT: %i13 = add i8 %i12, %i8 ; X64-NEXT: --> (%i12 + %i8) U: full-set S: full-set Exits: <> LoopDispositions: { %bb6: Variant } ; X64-NEXT: %i14 = getelementptr inbounds i8, i8* %i7, i64 1 -; X64-NEXT: --> {(1 + %arg),+,1}<%bb6> U: [1,0) S: [1,0) Exits: ((-1 * (ptrtoint i8* %arg to i64)) + (ptrtoint i8* %arg1 to i64) + %arg) LoopDispositions: { %bb6: Computable } +; X64-NEXT: --> {(1 + %arg),+,1}<%bb6> U: full-set S: full-set Exits: ((-1 * (ptrtoint i8* %arg to i64)) + (ptrtoint i8* %arg1 to i64) + %arg) LoopDispositions: { %bb6: Computable } ; X64-NEXT: Determining loop execution counts for: @pr46786_c26_char ; X64-NEXT: Loop %bb6: backedge-taken count is (-1 + (-1 * (ptrtoint i8* %arg to i64)) + (ptrtoint i8* %arg1 to i64)) ; X64-NEXT: Loop %bb6: max backedge-taken count is -1 @@ -419,7 +419,7 @@ define void @pr46786_c26_char(i8* %arg, i8* %arg1, i8* %arg2) { ; X32-NEXT: %i13 = add i8 %i12, %i8 ; X32-NEXT: --> (%i12 + %i8) U: full-set S: full-set Exits: <> LoopDispositions: { %bb6: Variant } ; X32-NEXT: %i14 = getelementptr inbounds i8, i8* %i7, i64 1 -; X32-NEXT: --> {(1 + %arg),+,1}<%bb6> U: [1,0) S: [1,0) Exits: ((-1 * (ptrtoint i8* %arg to i32)) + (ptrtoint i8* %arg1 to i32) + %arg) LoopDispositions: { %bb6: Computable } +; X32-NEXT: --> {(1 + %arg),+,1}<%bb6> U: full-set S: full-set Exits: ((-1 * (ptrtoint i8* %arg to i32)) + (ptrtoint i8* %arg1 to i32) + %arg) LoopDispositions: { %bb6: Computable } ; X32-NEXT: Determining loop execution counts for: @pr46786_c26_char ; X32-NEXT: Loop %bb6: backedge-taken count is (-1 + (-1 * (ptrtoint i8* %arg to i32)) + (ptrtoint i8* %arg1 to i32)) ; X32-NEXT: Loop %bb6: max backedge-taken count is -1 @@ -479,7 +479,7 @@ define void @pr46786_c26_int(i32* %arg, i32* %arg1, i32* %arg2) { ; X64-NEXT: %i14 = add nsw i32 %i13, %i8 ; X64-NEXT: --> (%i13 + %i8) U: full-set S: full-set Exits: <> LoopDispositions: { %bb6: Variant } ; X64-NEXT: %i15 = getelementptr inbounds i32, i32* %i7, i64 1 -; X64-NEXT: --> {(4 + %arg),+,4}<%bb6> U: [4,0) S: [4,0) Exits: (4 + (4 * ((-4 + (-1 * (ptrtoint i32* %arg to i64)) + (ptrtoint i32* %arg1 to i64)) /u 4)) + %arg) LoopDispositions: { %bb6: Computable } +; X64-NEXT: --> {(4 + %arg),+,4}<%bb6> U: full-set S: full-set Exits: (4 + (4 * ((-4 + (-1 * (ptrtoint i32* %arg to i64)) + (ptrtoint i32* %arg1 to i64)) /u 4)) + %arg) LoopDispositions: { %bb6: Computable } ; X64-NEXT: Determining loop execution counts for: @pr46786_c26_int ; X64-NEXT: Loop %bb6: backedge-taken count is ((-4 + (-1 * (ptrtoint i32* %arg to i64)) + (ptrtoint i32* %arg1 to i64)) /u 4) ; X64-NEXT: Loop %bb6: max backedge-taken count is 4611686018427387903 @@ -502,13 +502,13 @@ define void @pr46786_c26_int(i32* %arg, i32* %arg1, i32* %arg2) { ; X32-NEXT: %i11 = ashr exact i64 %i10, 2 ; X32-NEXT: --> %i11 U: [-2147483648,2147483648) S: [-2147483648,2147483648) Exits: <> LoopDispositions: { %bb6: Variant } ; X32-NEXT: %i12 = getelementptr inbounds i32, i32* %arg2, i64 %i11 -; X32-NEXT: --> ((4 * (trunc i64 %i11 to i32)) + %arg2) U: full-set S: full-set Exits: <> LoopDispositions: { %bb6: Variant } +; X32-NEXT: --> ((4 * (trunc i64 %i11 to i32)) + %arg2) U: full-set S: full-set Exits: <> LoopDispositions: { %bb6: Variant } ; X32-NEXT: %i13 = load i32, i32* %i12, align 4 ; X32-NEXT: --> %i13 U: full-set S: full-set Exits: <> LoopDispositions: { %bb6: Variant } ; X32-NEXT: %i14 = add nsw i32 %i13, %i8 ; X32-NEXT: --> (%i13 + %i8) U: full-set S: full-set Exits: <> LoopDispositions: { %bb6: Variant } ; X32-NEXT: %i15 = getelementptr inbounds i32, i32* %i7, i64 1 -; X32-NEXT: --> {(4 + %arg),+,4}<%bb6> U: [4,0) S: [4,0) Exits: (4 + (4 * ((-4 + (-1 * (ptrtoint i32* %arg to i32)) + (ptrtoint i32* %arg1 to i32)) /u 4)) + %arg) LoopDispositions: { %bb6: Computable } +; X32-NEXT: --> {(4 + %arg),+,4}<%bb6> U: full-set S: full-set Exits: (4 + (4 * ((-4 + (-1 * (ptrtoint i32* %arg to i32)) + (ptrtoint i32* %arg1 to i32)) /u 4)) + %arg) LoopDispositions: { %bb6: Computable } ; X32-NEXT: Determining loop execution counts for: @pr46786_c26_int ; X32-NEXT: Loop %bb6: backedge-taken count is ((-4 + (-1 * (ptrtoint i32* %arg to i32)) + (ptrtoint i32* %arg1 to i32)) /u 4) ; X32-NEXT: Loop %bb6: max backedge-taken count is 1073741823 diff --git a/llvm/test/Analysis/ScalarEvolution/sdiv.ll b/llvm/test/Analysis/ScalarEvolution/sdiv.ll index b708d5a1a2f4..603ce67843c9 100644 --- a/llvm/test/Analysis/ScalarEvolution/sdiv.ll +++ b/llvm/test/Analysis/ScalarEvolution/sdiv.ll @@ -18,7 +18,7 @@ define dso_local void @_Z4loopi(i32 %width) local_unnamed_addr #0 { ; CHECK-NEXT: %idxprom = sext i32 %rem to i64 ; CHECK-NEXT: --> ({0,+,1}<%for.cond> /u 2) U: [0,2147483648) S: [0,2147483648) Exits: ((zext i32 %width to i64) /u 2) LoopDispositions: { %for.cond: Computable } ; CHECK-NEXT: %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* %storage, i64 0, i64 %idxprom -; CHECK-NEXT: --> ((4 * ({0,+,1}<%for.cond> /u 2)) + %storage) U: [0,-3) S: [-9223372036854775808,9223372036854775805) Exits: ((4 * ((zext i32 %width to i64) /u 2)) + %storage) LoopDispositions: { %for.cond: Computable } +; CHECK-NEXT: --> ((4 * ({0,+,1}<%for.cond> /u 2)) + %storage) U: [0,-3) S: [-9223372036854775808,9223372036854775805) Exits: ((4 * ((zext i32 %width to i64) /u 2)) + %storage) LoopDispositions: { %for.cond: Computable } ; CHECK-NEXT: %1 = load i32, i32* %arrayidx, align 4 ; CHECK-NEXT: --> %1 U: full-set S: full-set Exits: <> LoopDispositions: { %for.cond: Variant } ; CHECK-NEXT: %call = call i32 @_Z3adji(i32 %1) diff --git a/llvm/test/Analysis/ScalarEvolution/srem.ll b/llvm/test/Analysis/ScalarEvolution/srem.ll index 416209a80cab..2814fe9a5f40 100644 --- a/llvm/test/Analysis/ScalarEvolution/srem.ll +++ b/llvm/test/Analysis/ScalarEvolution/srem.ll @@ -18,7 +18,7 @@ define dso_local void @_Z4loopi(i32 %width) local_unnamed_addr #0 { ; CHECK-NEXT: %idxprom = sext i32 %rem to i64 ; CHECK-NEXT: --> (zext i1 {false,+,true}<%for.cond> to i64) U: [0,2) S: [0,2) Exits: (zext i1 (trunc i32 %width to i1) to i64) LoopDispositions: { %for.cond: Computable } ; CHECK-NEXT: %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* %storage, i64 0, i64 %idxprom -; CHECK-NEXT: --> ((4 * (zext i1 {false,+,true}<%for.cond> to i64)) + %storage) U: [0,-3) S: [-9223372036854775808,9223372036854775805) Exits: ((4 * (zext i1 (trunc i32 %width to i1) to i64)) + %storage) LoopDispositions: { %for.cond: Computable } +; CHECK-NEXT: --> ((4 * (zext i1 {false,+,true}<%for.cond> to i64)) + %storage) U: [0,-3) S: [-9223372036854775808,9223372036854775805) Exits: ((4 * (zext i1 (trunc i32 %width to i1) to i64)) + %storage) LoopDispositions: { %for.cond: Computable } ; CHECK-NEXT: %1 = load i32, i32* %arrayidx, align 4 ; CHECK-NEXT: --> %1 U: full-set S: full-set Exits: <> LoopDispositions: { %for.cond: Variant } ; CHECK-NEXT: %call = call i32 @_Z3adji(i32 %1) diff --git a/llvm/test/Transforms/IndVarSimplify/eliminate-exit-no-dl.ll b/llvm/test/Transforms/IndVarSimplify/eliminate-exit-no-dl.ll index d8e0484b5207..5a6e2678bf42 100644 --- a/llvm/test/Transforms/IndVarSimplify/eliminate-exit-no-dl.ll +++ b/llvm/test/Transforms/IndVarSimplify/eliminate-exit-no-dl.ll @@ -16,7 +16,8 @@ define void @foo() { ; CHECK: bb3: ; CHECK-NEXT: [[TMP4:%.*]] = getelementptr inbounds i8, i8* getelementptr inbounds ([0 x i8], [0 x i8]* @global, i64 0, i64 2), i64 -1 ; CHECK-NEXT: [[TMP6:%.*]] = load i8, i8* [[TMP4]], align 1 -; CHECK-NEXT: br i1 false, label [[BB7:%.*]], label [[BB11:%.*]] +; CHECK-NEXT: [[TMP5:%.*]] = icmp ugt i8* [[TMP4]], getelementptr inbounds ([0 x i8], [0 x i8]* @global, i64 0, i64 500) +; CHECK-NEXT: br i1 [[TMP5]], label [[BB7:%.*]], label [[BB11:%.*]] ; CHECK: bb7: ; CHECK-NEXT: [[TMP8:%.*]] = zext i8 [[TMP6]] to i64 ; CHECK-NEXT: br i1 true, label [[BB11]], label [[BB3]] diff --git a/llvm/test/Transforms/LoopStrengthReduce/X86/expander-crashes.ll b/llvm/test/Transforms/LoopStrengthReduce/X86/expander-crashes.ll index d7c3e3ae08da..a10d432f5c43 100644 --- a/llvm/test/Transforms/LoopStrengthReduce/X86/expander-crashes.ll +++ b/llvm/test/Transforms/LoopStrengthReduce/X86/expander-crashes.ll @@ -17,7 +17,7 @@ define i64 @blam(%struct.hoge* %start, %struct.hoge* %end, %struct.hoge* %ptr.2) ; CHECK-NEXT: [[LSR_IV5:%.*]] = phi i64 [ [[LSR_IV_NEXT6:%.*]], [[LOOP_1_HEADER]] ], [ [[START1]], [[ENTRY:%.*]] ] ; CHECK-NEXT: [[IV:%.*]] = phi %struct.hoge* [ [[IV_NEXT:%.*]], [[LOOP_1_HEADER]] ], [ [[START]], [[ENTRY]] ] ; CHECK-NEXT: [[IV_NEXT]] = getelementptr inbounds [[STRUCT_HOGE:%.*]], %struct.hoge* [[IV]], i64 1 -; CHECK-NEXT: [[LSR_IV_NEXT6]] = add nuw i64 [[LSR_IV5]], 16 +; CHECK-NEXT: [[LSR_IV_NEXT6]] = add i64 [[LSR_IV5]], 16 ; CHECK-NEXT: [[EC:%.*]] = icmp eq %struct.hoge* [[IV_NEXT]], [[END:%.*]] ; CHECK-NEXT: br i1 [[EC]], label [[LOOP_2_PH:%.*]], label [[LOOP_1_HEADER]] ; CHECK: loop.2.ph: diff --git a/polly/test/ScopInfo/NonAffine/non-affine-loop-condition-dependent-access_2.ll b/polly/test/ScopInfo/NonAffine/non-affine-loop-condition-dependent-access_2.ll index e4a930c57822..6b216bef4166 100644 --- a/polly/test/ScopInfo/NonAffine/non-affine-loop-condition-dependent-access_2.ll +++ b/polly/test/ScopInfo/NonAffine/non-affine-loop-condition-dependent-access_2.ll @@ -96,9 +96,9 @@ ; ALL-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] ; ALL-NEXT: { Stmt_bb15__TO__bb25[i0, i1] -> MemRef_A[i1] }; ; ALL-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] -; ALL-NEXT: { Stmt_bb15__TO__bb25[i0, i1] -> MemRef_A[o0] : 0 <= o0 <= 2305843009213693951 }; +; ALL-NEXT: { Stmt_bb15__TO__bb25[i0, i1] -> MemRef_A[o0] }; ; ALL-NEXT: MayWriteAccess := [Reduction Type: NONE] [Scalar: 0] -; ALL-NEXT: { Stmt_bb15__TO__bb25[i0, i1] -> MemRef_A[o0] : 0 <= o0 <= 2305843009213693951 }; +; ALL-NEXT: { Stmt_bb15__TO__bb25[i0, i1] -> MemRef_A[o0] }; ; ALL-NEXT: } ; ; void f(int *A) { diff --git a/polly/test/ScopInfo/pointer-type-expressions.ll b/polly/test/ScopInfo/pointer-type-expressions.ll index 1db2733e1606..fbaf25691820 100644 --- a/polly/test/ScopInfo/pointer-type-expressions.ll +++ b/polly/test/ScopInfo/pointer-type-expressions.ll @@ -35,7 +35,7 @@ return: ; CHECK: Assumed Context: ; CHECK-NEXT: { : } ; CHECK-NEXT: Invalid Context: -; CHECK-NEXT: { : false } +; CHECK-NEXT: { : N >= 1152921504606846977 and (P < 0 or P > 0) } ; CHECK: Stmt_store ; CHECK: Domain := diff --git a/polly/test/ScopInfo/unsigned-division-5.ll b/polly/test/ScopInfo/unsigned-division-5.ll index 6d82873d23e7..3d16c6c88393 100644 --- a/polly/test/ScopInfo/unsigned-division-5.ll +++ b/polly/test/ScopInfo/unsigned-division-5.ll @@ -9,13 +9,13 @@ ; CHECK: Invariant Accesses: { ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] ; CHECK-NEXT: [N] -> { Stmt_for_body[i0] -> MemRef_A[o0] : -2 + 5N <= 3o0 <= 5N }; -; CHECK-NEXT: Execution Context: [N] -> { : 0 < N <= 1844674407370955161 } +; CHECK-NEXT: Execution Context: [N] -> { : 0 < N <= 1383505805528216371 } ; CHECK-NEXT: } ; ; CHECK: Assumed Context: ; CHECK-NEXT: [N] -> { : } ; CHECK-NEXT: Invalid Context: -; CHECK-NEXT: [N] -> { : N >= 1844674407370955162 } +; CHECK-NEXT: [N] -> { : N >= 1383505805528216372 } ; CHECK: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0] ; CHECK-NEXT: [N] -> { Stmt_for_body[i0] -> MemRef_A[o0] : -2 + i0 <= 3o0 <= i0 };