[llvm] [SCEV] Fix incorrect nsw inference for multiply of addrec (PR #66500)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 15 05:19:37 PDT 2023
https://github.com/nikic created https://github.com/llvm/llvm-project/pull/66500
SCEV currently preserves the nsw flag when performing an nsw multiply of an nsw addrec. While this is legal for nuw, this is not generally the case for nsw.
This is because nsw mul does not distribute over nsw add: https://alive2.llvm.org/ce/z/mergCt
Instead, we need either both nuw and nsw to be set (https://alive2.llvm.org/ce/z/7wpgGc) or explicitly prove that the distributed multiplications are also nsw
(https://alive2.llvm.org/ce/z/wef9su).
Fixes https://github.com/llvm/llvm-project/issues/66066.
>From 9d4de6248c2869103a9046fa0e620966c4cee6a7 Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Fri, 15 Sep 2023 10:01:43 +0200
Subject: [PATCH] [SCEV] Fix incorrect nsw inference for multiply of addrec
SCEV currently preserves the nsw flag when performing an nsw
multiply of an nsw addrec. While this is legal for nuw, this is
not generally the case for nsw.
This is because nsw mul does not distribute over nsw add:
https://alive2.llvm.org/ce/z/mergCt
Instead, we need either both nuw and nsw to be set
(https://alive2.llvm.org/ce/z/7wpgGc) or explicitly prove
that the distributed multiplications are also nsw
(https://alive2.llvm.org/ce/z/wef9su).
Fixes https://github.com/llvm/llvm-project/issues/66066.
---
llvm/lib/Analysis/ScalarEvolution.cpp | 28 +++--
.../constant_functions_multi_dim.ll | 4 +-
.../LoopAccessAnalysis/number-of-memchecks.ll | 2 +-
.../ScalarEvolution/flags-from-poison.ll | 22 ++--
.../max-backedge-taken-count-guard-info.ll | 12 +-
llvm/test/Analysis/ScalarEvolution/nsw.ll | 4 +-
.../test/Transforms/IndVarSimplify/pr66066.ll | 5 +-
.../LoopDataPrefetch/AArch64/pr43784.ll | 117 ------------------
8 files changed, 44 insertions(+), 150 deletions(-)
delete mode 100644 llvm/test/Transforms/LoopDataPrefetch/AArch64/pr43784.ll
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index f951068c4c79c09..00b1af73671c041 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -3269,18 +3269,28 @@ const SCEV *ScalarEvolution::getMulExpr(SmallVectorImpl<const SCEV *> &Ops,
SmallVector<const SCEV *, 4> NewOps;
NewOps.reserve(AddRec->getNumOperands());
const SCEV *Scale = getMulExpr(LIOps, SCEV::FlagAnyWrap, Depth + 1);
- for (unsigned i = 0, e = AddRec->getNumOperands(); i != e; ++i)
+
+ // If both the mul and addrec are nuw, we can preserve nuw.
+ // If both the mul and addrec are nsw, we can only preserve nsw if either
+ // a) they are also nuw, or
+ // b) all multiplications of addrec operands with scale are nsw.
+ SCEV::NoWrapFlags Flags =
+ AddRec->getNoWrapFlags(ComputeFlags({Scale, AddRec}));
+
+ for (unsigned i = 0, e = AddRec->getNumOperands(); i != e; ++i) {
NewOps.push_back(getMulExpr(Scale, AddRec->getOperand(i),
SCEV::FlagAnyWrap, Depth + 1));
- // Build the new addrec. Propagate the NUW and NSW flags if both the
- // outer mul and the inner addrec are guaranteed to have no overflow.
- //
- // No self-wrap cannot be guaranteed after changing the step size, but
- // will be inferred if either NUW or NSW is true.
- SCEV::NoWrapFlags Flags = ComputeFlags({Scale, AddRec});
- const SCEV *NewRec = getAddRecExpr(
- NewOps, AddRec->getLoop(), AddRec->getNoWrapFlags(Flags));
+ if (hasFlags(Flags, SCEV::FlagNSW) && !hasFlags(Flags, SCEV::FlagNUW)) {
+ ConstantRange NSWRegion = ConstantRange::makeGuaranteedNoWrapRegion(
+ Instruction::Mul, getSignedRange(Scale),
+ OverflowingBinaryOperator::NoSignedWrap);
+ if (!NSWRegion.contains(getSignedRange(AddRec->getOperand(i))))
+ Flags = clearFlags(Flags, SCEV::FlagNSW);
+ }
+ }
+
+ const SCEV *NewRec = getAddRecExpr(NewOps, AddRec->getLoop(), Flags);
// If all of the other operands were loop invariant, we are done.
if (Ops.size() == 1) return NewRec;
diff --git a/llvm/test/Analysis/Delinearization/constant_functions_multi_dim.ll b/llvm/test/Analysis/Delinearization/constant_functions_multi_dim.ll
index 00fcbff02e2746a..3044a4868260b4d 100644
--- a/llvm/test/Analysis/Delinearization/constant_functions_multi_dim.ll
+++ b/llvm/test/Analysis/Delinearization/constant_functions_multi_dim.ll
@@ -4,14 +4,14 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
; CHECK: Inst: %tmp = load float, ptr %arrayidx, align 4
; CHECK-NEXT: In Loop with Header: for.inc
-; CHECK-NEXT: AccessFunction: {(4 * %N * %call),+,4}<nsw><%for.inc>
+; CHECK-NEXT: AccessFunction: {(4 * %N * %call),+,4}<%for.inc>
; CHECK-NEXT: Base offset: %A
; CHECK-NEXT: ArrayDecl[UnknownSize][%N] with elements of 4 bytes.
; CHECK-NEXT: ArrayRef[%call][{0,+,1}<nuw><nsw><%for.inc>]
; CHECK: Inst: %tmp5 = load float, ptr %arrayidx4, align 4
; CHECK-NEXT: In Loop with Header: for.inc
-; CHECK-NEXT: AccessFunction: {(4 * %call1),+,(4 * %N)}<nsw><%for.inc>
+; CHECK-NEXT: AccessFunction: {(4 * %call1),+,(4 * %N)}<%for.inc>
; CHECK-NEXT: Base offset: %B
; CHECK-NEXT: ArrayDecl[UnknownSize][%N] with elements of 4 bytes.
; CHECK-NEXT: ArrayRef[{0,+,1}<nuw><nsw><%for.inc>][%call1]
diff --git a/llvm/test/Analysis/LoopAccessAnalysis/number-of-memchecks.ll b/llvm/test/Analysis/LoopAccessAnalysis/number-of-memchecks.ll
index 8ddcc152d11c6b9..c268cc55880c15f 100644
--- a/llvm/test/Analysis/LoopAccessAnalysis/number-of-memchecks.ll
+++ b/llvm/test/Analysis/LoopAccessAnalysis/number-of-memchecks.ll
@@ -247,7 +247,7 @@ for.end: ; preds = %for.body
; CHECK-NEXT: Grouped accesses:
; CHECK-NEXT: Group {{.*}}[[ZERO]]:
; CHECK-NEXT: (Low: ((2 * %offset) + %a) High: (10000 + (2 * %offset) + %a))
-; CHECK-NEXT: Member: {((2 * %offset) + %a),+,2}<nw><%for.body>
+; CHECK-NEXT: Member: {((2 * %offset) + %a),+,2}<%for.body>
; CHECK-NEXT: Group {{.*}}[[ONE]]:
; CHECK-NEXT: (Low: %a High: (10000 + %a))
; CHECK-NEXT: Member: {%a,+,2}<nw><%for.body>
diff --git a/llvm/test/Analysis/ScalarEvolution/flags-from-poison.ll b/llvm/test/Analysis/ScalarEvolution/flags-from-poison.ll
index c6c9ff082ddd68b..a5bdee5c3b459bb 100644
--- a/llvm/test/Analysis/ScalarEvolution/flags-from-poison.ll
+++ b/llvm/test/Analysis/ScalarEvolution/flags-from-poison.ll
@@ -937,9 +937,9 @@ define void @test-mul-propagates-poison(ptr %input, i32 %offset, i32 %numIterati
; CHECK-NEXT: %index32 = add nsw i32 %i, %offset
; CHECK-NEXT: --> {%offset,+,1}<nsw><%loop> U: full-set S: full-set Exits: (-1 + %offset + %numIterations) LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %indexmul = mul nsw i32 %index32, %offset
-; CHECK-NEXT: --> {(%offset * %offset),+,%offset}<nsw><%loop> U: full-set S: full-set Exits: ((-1 + %offset + %numIterations) * %offset) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: --> {(%offset * %offset),+,%offset}<%loop> U: full-set S: full-set Exits: ((-1 + %offset + %numIterations) * %offset) LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %ptr = getelementptr inbounds float, ptr %input, i32 %indexmul
-; CHECK-NEXT: --> {((4 * (sext i32 (%offset * %offset) to i64))<nsw> + %input),+,(4 * (sext i32 %offset to i64))<nsw>}<nw><%loop> U: full-set S: full-set Exits: ((4 * (sext i32 (%offset * %offset) to i64))<nsw> + (4 * (zext i32 (-1 + %numIterations) to i64) * (sext i32 %offset to i64)) + %input) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: --> ((4 * (sext i32 {(%offset * %offset),+,%offset}<%loop> to i64))<nsw> + %input) U: full-set S: full-set Exits: ((4 * (sext i32 ((-1 + %offset + %numIterations) * %offset) to i64))<nsw> + %input) LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %nexti = add nsw i32 %i, 1
; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop> U: [1,-2147483648) S: [1,-2147483648) Exits: %numIterations LoopDispositions: { %loop: Computable }
; CHECK-NEXT: Determining loop execution counts for: @test-mul-propagates-poison
@@ -1245,11 +1245,11 @@ define void @test-shl-nsw(ptr %input, i32 %start, i32 %numIterations) {
; CHECK-NEXT: %i = phi i32 [ %nexti, %loop ], [ %start, %entry ]
; CHECK-NEXT: --> {%start,+,1}<nsw><%loop> U: full-set S: full-set Exits: (-1 + %numIterations) LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %index32 = shl nsw i32 %i, 8
-; CHECK-NEXT: --> {(256 * %start),+,256}<nsw><%loop> U: [0,-255) S: [-2147483648,2147483393) Exits: (-256 + (256 * %numIterations)) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: --> {(256 * %start),+,256}<%loop> U: [0,-255) S: [-2147483648,2147483393) Exits: (-256 + (256 * %numIterations)) LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %index64 = sext i32 %index32 to i64
-; CHECK-NEXT: --> {(sext i32 (256 * %start) to i64),+,256}<nsw><%loop> U: [0,-255) S: [-2147483648,1101659110913) Exits: ((sext i32 (256 * %start) to i64) + (256 * (zext i32 (-1 + (-1 * %start) + %numIterations) to i64))<nuw><nsw>) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: --> (sext i32 {(256 * %start),+,256}<%loop> to i64) U: [0,-255) S: [-2147483648,2147483393) Exits: (sext i32 (-256 + (256 * %numIterations)) to i64) LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %ptr = getelementptr inbounds float, ptr %input, i64 %index64
-; CHECK-NEXT: --> {((4 * (sext i32 (256 * %start) to i64))<nsw> + %input),+,1024}<nw><%loop> U: full-set S: full-set Exits: ((4 * (sext i32 (256 * %start) to i64))<nsw> + (1024 * (zext i32 (-1 + (-1 * %start) + %numIterations) to i64))<nuw><nsw> + %input) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: --> ((4 * (sext i32 {(256 * %start),+,256}<%loop> to i64))<nsw> + %input) U: full-set S: full-set Exits: ((4 * (sext i32 (-256 + (256 * %numIterations)) to i64))<nsw> + %input) LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %nexti = add nsw i32 %i, 1
; CHECK-NEXT: --> {(1 + %start)<nsw>,+,1}<nsw><%loop> U: [-2147483647,-2147483648) S: [-2147483647,-2147483648) Exits: %numIterations LoopDispositions: { %loop: Computable }
; CHECK-NEXT: Determining loop execution counts for: @test-shl-nsw
@@ -1325,11 +1325,11 @@ define void @test-shl-nuw-nsw(ptr %input, i32 %start, i32 %numIterations) {
; CHECK-NEXT: %i = phi i32 [ %nexti, %loop ], [ %start, %entry ]
; CHECK-NEXT: --> {%start,+,1}<nsw><%loop> U: full-set S: full-set Exits: (-1 + %numIterations) LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %index32 = shl nuw nsw i32 %i, 31
-; CHECK-NEXT: --> {(-2147483648 * %start),+,-2147483648}<nsw><%loop> U: [0,-2147483647) S: [-2147483648,1) Exits: (-2147483648 + (-2147483648 * %numIterations)) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: --> {(-2147483648 * %start),+,-2147483648}<%loop> U: [0,-2147483647) S: [-2147483648,1) Exits: (-2147483648 + (-2147483648 * %numIterations)) LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %index64 = sext i32 %index32 to i64
-; CHECK-NEXT: --> {(sext i32 (-2147483648 * %start) to i64),+,-2147483648}<nsw><%loop> U: [0,-2147483647) S: [-9223372036854775808,1) Exits: ((sext i32 (-2147483648 * %start) to i64) + (-2147483648 * (zext i32 (-1 + (-1 * %start) + %numIterations) to i64))<nsw>) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: --> (sext i32 {(-2147483648 * %start),+,-2147483648}<%loop> to i64) U: [0,-2147483647) S: [-2147483648,1) Exits: (sext i32 (-2147483648 + (-2147483648 * %numIterations)) to i64) LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %ptr = getelementptr inbounds float, ptr %input, i64 %index64
-; CHECK-NEXT: --> {((4 * (sext i32 (-2147483648 * %start) to i64))<nsw> + %input),+,-8589934592}<nw><%loop> U: full-set S: full-set Exits: ((4 * (sext i32 (-2147483648 * %start) to i64))<nsw> + (-8589934592 * (zext i32 (-1 + (-1 * %start) + %numIterations) to i64)) + %input) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: --> ((4 * (sext i32 {(-2147483648 * %start),+,-2147483648}<%loop> to i64))<nsw> + %input) U: full-set S: full-set Exits: ((4 * (sext i32 (-2147483648 + (-2147483648 * %numIterations)) to i64))<nsw> + %input) LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %nexti = add nsw i32 %i, 1
; CHECK-NEXT: --> {(1 + %start)<nsw>,+,1}<nsw><%loop> U: [-2147483647,-2147483648) S: [-2147483647,-2147483648) Exits: %numIterations LoopDispositions: { %loop: Computable }
; CHECK-NEXT: Determining loop execution counts for: @test-shl-nuw-nsw
@@ -1405,11 +1405,11 @@ define void @test-shl-nsw-edgecase(ptr %input, i32 %start, i32 %numIterations) {
; CHECK-NEXT: %i = phi i32 [ %nexti, %loop ], [ %start, %entry ]
; CHECK-NEXT: --> {%start,+,1}<nsw><%loop> U: full-set S: full-set Exits: (-1 + %numIterations) LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %index32 = shl nsw i32 %i, 30
-; CHECK-NEXT: --> {(1073741824 * %start),+,1073741824}<nsw><%loop> U: [0,-1073741823) S: [-2147483648,1073741825) Exits: (-1073741824 + (1073741824 * %numIterations)) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: --> {(1073741824 * %start),+,1073741824}<%loop> U: [0,-1073741823) S: [-2147483648,1073741825) Exits: (-1073741824 + (1073741824 * %numIterations)) LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %index64 = sext i32 %index32 to i64
-; CHECK-NEXT: --> {(sext i32 (1073741824 * %start) to i64),+,1073741824}<nsw><%loop> U: [0,-1073741823) S: [-2147483648,4611686018427387905) Exits: ((sext i32 (1073741824 * %start) to i64) + (1073741824 * (zext i32 (-1 + (-1 * %start) + %numIterations) to i64))<nuw><nsw>) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: --> (sext i32 {(1073741824 * %start),+,1073741824}<%loop> to i64) U: [0,-1073741823) S: [-2147483648,1073741825) Exits: (sext i32 (-1073741824 + (1073741824 * %numIterations)) to i64) LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %ptr = getelementptr inbounds float, ptr %input, i64 %index64
-; CHECK-NEXT: --> {((4 * (sext i32 (1073741824 * %start) to i64))<nsw> + %input),+,4294967296}<nw><%loop> U: full-set S: full-set Exits: ((4 * (sext i32 (1073741824 * %start) to i64))<nsw> + (4294967296 * (zext i32 (-1 + (-1 * %start) + %numIterations) to i64))<nuw> + %input) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: --> ((4 * (sext i32 {(1073741824 * %start),+,1073741824}<%loop> to i64))<nsw> + %input) U: full-set S: full-set Exits: ((4 * (sext i32 (-1073741824 + (1073741824 * %numIterations)) to i64))<nsw> + %input) LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %nexti = add nsw i32 %i, 1
; CHECK-NEXT: --> {(1 + %start)<nsw>,+,1}<nsw><%loop> U: [-2147483647,-2147483648) S: [-2147483647,-2147483648) Exits: %numIterations LoopDispositions: { %loop: Computable }
; CHECK-NEXT: Determining loop execution counts for: @test-shl-nsw-edgecase
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 e6fbcbe5333f82e..eb8e9dd09dc4fb4 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
@@ -9,7 +9,7 @@ define void @test_guard_less_than_16(ptr nocapture %a, i64 %i) {
; CHECK-NEXT: %iv = phi i64 [ %iv.next, %loop ], [ %i, %entry ]
; CHECK-NEXT: --> {%i,+,1}<nuw><nsw><%loop> U: full-set S: full-set Exits: 15 LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %idx = getelementptr inbounds i32, ptr %a, i64 %iv
-; CHECK-NEXT: --> {((4 * %i) + %a),+,4}<nw><%loop> U: full-set S: full-set Exits: (60 + %a) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: --> {((4 * %i) + %a),+,4}<%loop> U: full-set S: full-set Exits: (60 + %a) LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %iv.next = add nuw nsw i64 %iv, 1
; CHECK-NEXT: --> {(1 + %i),+,1}<nuw><nsw><%loop> U: full-set S: full-set Exits: 16 LoopDispositions: { %loop: Computable }
; CHECK-NEXT: Determining loop execution counts for: @test_guard_less_than_16
@@ -42,7 +42,7 @@ define void @test_guard_less_than_16_operands_swapped(ptr nocapture %a, i64 %i)
; CHECK-NEXT: %iv = phi i64 [ %iv.next, %loop ], [ %i, %entry ]
; CHECK-NEXT: --> {%i,+,1}<nuw><nsw><%loop> U: full-set S: full-set Exits: 15 LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %idx = getelementptr inbounds i32, ptr %a, i64 %iv
-; CHECK-NEXT: --> {((4 * %i) + %a),+,4}<nw><%loop> U: full-set S: full-set Exits: (60 + %a) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: --> {((4 * %i) + %a),+,4}<%loop> U: full-set S: full-set Exits: (60 + %a) LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %iv.next = add nuw nsw i64 %iv, 1
; CHECK-NEXT: --> {(1 + %i),+,1}<nuw><nsw><%loop> U: full-set S: full-set Exits: 16 LoopDispositions: { %loop: Computable }
; CHECK-NEXT: Determining loop execution counts for: @test_guard_less_than_16_operands_swapped
@@ -75,7 +75,7 @@ define void @test_guard_less_than_16_branches_flipped(ptr nocapture %a, i64 %i)
; CHECK-NEXT: %iv = phi i64 [ %iv.next, %loop ], [ %i, %entry ]
; CHECK-NEXT: --> {%i,+,1}<nuw><nsw><%loop> U: full-set S: full-set Exits: 15 LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %idx = getelementptr inbounds i32, ptr %a, i64 %iv
-; CHECK-NEXT: --> {((4 * %i) + %a),+,4}<nw><%loop> U: full-set S: full-set Exits: (60 + %a) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: --> {((4 * %i) + %a),+,4}<%loop> U: full-set S: full-set Exits: (60 + %a) LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %iv.next = add nuw nsw i64 %iv, 1
; CHECK-NEXT: --> {(1 + %i),+,1}<nuw><nsw><%loop> U: full-set S: full-set Exits: 16 LoopDispositions: { %loop: Computable }
; CHECK-NEXT: Determining loop execution counts for: @test_guard_less_than_16_branches_flipped
@@ -108,7 +108,7 @@ define void @test_guard_uge_16_branches_flipped(ptr nocapture %a, i64 %i) {
; CHECK-NEXT: %iv = phi i64 [ %iv.next, %loop ], [ %i, %entry ]
; CHECK-NEXT: --> {%i,+,1}<nuw><nsw><%loop> U: full-set S: full-set Exits: 15 LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %idx = getelementptr inbounds i32, ptr %a, i64 %iv
-; CHECK-NEXT: --> {((4 * %i) + %a),+,4}<nw><%loop> U: full-set S: full-set Exits: (60 + %a) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: --> {((4 * %i) + %a),+,4}<%loop> U: full-set S: full-set Exits: (60 + %a) LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %iv.next = add nuw nsw i64 %iv, 1
; CHECK-NEXT: --> {(1 + %i),+,1}<nuw><nsw><%loop> U: full-set S: full-set Exits: 16 LoopDispositions: { %loop: Computable }
; CHECK-NEXT: Determining loop execution counts for: @test_guard_uge_16_branches_flipped
@@ -1219,7 +1219,7 @@ define void @test_guard_slt_sgt_2(ptr nocapture %a, i64 %i) {
; CHECK-NEXT: %iv = phi i64 [ %iv.next, %loop ], [ %i, %entry ]
; CHECK-NEXT: --> {%i,+,1}<nuw><nsw><%loop> U: full-set S: full-set Exits: 17 LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %idx = getelementptr inbounds i32, ptr %a, i64 %iv
-; CHECK-NEXT: --> {((4 * %i) + %a),+,4}<nw><%loop> U: full-set S: full-set Exits: (68 + %a) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: --> {((4 * %i) + %a),+,4}<%loop> U: full-set S: full-set Exits: (68 + %a) LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %iv.next = add nuw nsw i64 %iv, 1
; CHECK-NEXT: --> {(1 + %i),+,1}<nuw><nsw><%loop> U: full-set S: full-set Exits: 18 LoopDispositions: { %loop: Computable }
; CHECK-NEXT: Determining loop execution counts for: @test_guard_slt_sgt_2
@@ -1293,7 +1293,7 @@ define void @test_guard_sle_sge_2(ptr nocapture %a, i64 %i) {
; CHECK-NEXT: %iv = phi i64 [ %iv.next, %loop ], [ %i, %entry ]
; CHECK-NEXT: --> {%i,+,1}<nuw><nsw><%loop> U: full-set S: full-set Exits: 17 LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %idx = getelementptr inbounds i32, ptr %a, i64 %iv
-; CHECK-NEXT: --> {((4 * %i) + %a),+,4}<nw><%loop> U: full-set S: full-set Exits: (68 + %a) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: --> {((4 * %i) + %a),+,4}<%loop> U: full-set S: full-set Exits: (68 + %a) LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %iv.next = add nuw nsw i64 %iv, 1
; CHECK-NEXT: --> {(1 + %i),+,1}<nuw><nsw><%loop> U: full-set S: full-set Exits: 18 LoopDispositions: { %loop: Computable }
; CHECK-NEXT: Determining loop execution counts for: @test_guard_sle_sge_2
diff --git a/llvm/test/Analysis/ScalarEvolution/nsw.ll b/llvm/test/Analysis/ScalarEvolution/nsw.ll
index ac02036d2ece614..031ec46edcdaca1 100644
--- a/llvm/test/Analysis/ScalarEvolution/nsw.ll
+++ b/llvm/test/Analysis/ScalarEvolution/nsw.ll
@@ -439,7 +439,7 @@ return:
ret void
}
-; FIXME: {-128,+,-128} should not be <nsw>.
+; {-128,+,-128} should not be <nsw>.
define void @pr66066() {
; CHECK-LABEL: 'pr66066'
; CHECK-NEXT: Classifying expressions for: @pr66066
@@ -448,7 +448,7 @@ define void @pr66066() {
; CHECK-NEXT: %iv.dec = add i8 %iv, -1
; CHECK-NEXT: --> {0,+,-1}<nsw><%loop> U: [-1,1) S: [-1,1) Exits: -1 LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %shl = shl i8 %iv, 7
-; CHECK-NEXT: --> {-128,+,-128}<nsw><%loop> U: [-128,-127) S: [-128,-127) Exits: 0 LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: --> {-128,+,-128}<%loop> U: [0,-127) S: [-128,1) Exits: 0 LoopDispositions: { %loop: Computable }
; CHECK-NEXT: Determining loop execution counts for: @pr66066
; CHECK-NEXT: Loop %loop: backedge-taken count is 1
; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 1
diff --git a/llvm/test/Transforms/IndVarSimplify/pr66066.ll b/llvm/test/Transforms/IndVarSimplify/pr66066.ll
index c88ca5ed639e2e3..cfd29876b302db4 100644
--- a/llvm/test/Transforms/IndVarSimplify/pr66066.ll
+++ b/llvm/test/Transforms/IndVarSimplify/pr66066.ll
@@ -1,7 +1,7 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3
; RUN: opt -S -passes=indvars < %s | FileCheck %s
-; FIXME: The comparison should not get folded to false.
+; The comparison should not get folded to false.
define void @test() {
; CHECK-LABEL: define void @test() {
; CHECK-NEXT: entry:
@@ -11,7 +11,8 @@ define void @test() {
; CHECK-NEXT: [[IV_DEC]] = add nsw i8 [[IV]], -1
; CHECK-NEXT: [[SHL:%.*]] = shl i8 [[IV]], 7
; CHECK-NEXT: call void @use(i8 [[SHL]])
-; CHECK-NEXT: br i1 false, label [[EXIT:%.*]], label [[LOOP]]
+; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[SHL]], 0
+; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
; CHECK: exit:
; CHECK-NEXT: ret void
;
diff --git a/llvm/test/Transforms/LoopDataPrefetch/AArch64/pr43784.ll b/llvm/test/Transforms/LoopDataPrefetch/AArch64/pr43784.ll
deleted file mode 100644
index c3fed4bf7c9993b..000000000000000
--- a/llvm/test/Transforms/LoopDataPrefetch/AArch64/pr43784.ll
+++ /dev/null
@@ -1,117 +0,0 @@
-; RUN: opt -mcpu=kryo -passes=loop-simplify,loop-data-prefetch -max-prefetch-iters-ahead=1000 -min-prefetch-stride=16 -S < %s | FileCheck %s
-
-target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
-target triple = "aarch64-unknown-linux-gnu"
-
-%struct._Chv = type { i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, %struct._DV, ptr }
-%struct._DV = type { i32, i32, i32, ptr }
-
-declare ptr @f_entries() local_unnamed_addr
-
-define i32 @f(ptr %chv, i32 %npivot, ptr %pivotsizes, ptr %sizes) local_unnamed_addr {
-if.end:
- switch i32 undef, label %sw.default [
- i32 1, label %sw.epilog
- i32 3, label %sw.epilog
- i32 4, label %sw.epilog
- i32 5, label %sw.epilog
- i32 6, label %sw.epilog
- i32 7, label %sw.epilog
- ]
-
-sw.default: ; preds = %if.end
- unreachable
-
-sw.epilog: ; preds = %if.end, %if.end, %if.end, %if.end, %if.end, %if.end
- br label %if.end12
-
-if.end12: ; preds = %sw.epilog
- %nD13 = getelementptr inbounds %struct._Chv, ptr %chv, i64 0, i32 1
- %0 = load i32, ptr %nD13, align 4
- %nU15 = getelementptr inbounds %struct._Chv, ptr %chv, i64 0, i32 3
- %1 = load i32, ptr %nU15, align 4
- %add17 = add i32 %1, %0
- %call18 = call ptr @f_entries()
- switch i32 undef, label %sw.epilog2454 [
- i32 3, label %sw.bb213
- ]
-
-sw.bb213: ; preds = %if.end12
- switch i32 undef, label %sw.epilog2454 [
- i32 0, label %sw.bb214
- ]
-
-sw.bb214: ; preds = %sw.bb213
- br label %if.then220
-
-if.then220: ; preds = %sw.bb214
- %type230 = getelementptr inbounds %struct._Chv, ptr %chv, i64 0, i32 4
- %2 = load i32, ptr %type230, align 8
- br label %if.else319
-
-if.else319: ; preds = %if.then220
- switch i32 %2, label %sw.epilog2454 [
- i32 2, label %for.cond372.preheader
- ]
-
-for.cond372.preheader: ; preds = %if.else319
- %cmp3734342 = icmp sgt i32 %npivot, 0
- br i1 %cmp3734342, label %for.body374.lr.ph, label %sw.epilog2454
-
-for.body374.lr.ph: ; preds = %for.cond372.preheader
- br label %for.body374
-
-for.body374: ; preds = %for.body374.lr.ph
- %3 = load i32, ptr %pivotsizes, align 4
- %add377 = add i32 %3, 0
- br label %for.body381.lr.ph
-
-for.body381.lr.ph: ; preds = %for.body374
- %cmp3874327 = icmp slt i32 %add377, %add17
- br i1 %cmp3874327, label %for.body381.us, label %for.body381.preheader
-
-for.body381.preheader: ; preds = %for.body381.lr.ph
- ret i32 undef
-
-for.body381.us: ; preds = %for.cond386.for.end421_crit_edge.us, %for.body381.lr.ph
- %indvars.iv4991.us = phi i64 [ %indvars.iv.next4992.us, %for.cond386.for.end421_crit_edge.us ], [ undef, %for.body381.lr.ph ]
- %stride226.54337.us = phi i32 [ %dec423.us, %for.cond386.for.end421_crit_edge.us ], [ %add17, %for.body381.lr.ph ]
- %kstart225.54336.us = phi i32 [ %add422.us, %for.cond386.for.end421_crit_edge.us ], [ 0, %for.body381.lr.ph ]
- %4 = trunc i64 %indvars.iv4991.us to i32
- %5 = xor i32 %4, -1
- %add382.us = add i32 %add377, %5
- %sub383.us = add i32 %add382.us, %kstart225.54336.us
- br label %for.body388.us
-
-; CHECK: for.body388.us:
-; CHECK: call void @llvm.prefetch
-for.body388.us: ; preds = %for.inc418.us, %for.body381.us
- %kk224.3.in4330.us = phi i32 [ %sub383.us, %for.body381.us ], [ %kk224.3.us, %for.inc418.us ]
- %jj223.34329.us = phi i32 [ %add377, %for.body381.us ], [ %inc419.us, %for.inc418.us ]
- %kk224.3.us = add nsw i32 %kk224.3.in4330.us, 1
- %mul389.us = shl nsw i32 %kk224.3.us, 1
- %idxprom390.us = sext i32 %mul389.us to i64
- %arrayidx391.us = getelementptr inbounds double, ptr %call18, i64 %idxprom390.us
- %6 = load double, ptr %arrayidx391.us, align 8
- %call396.us = call double @Zabs(double %6)
- br label %for.inc418.us
-
-for.inc418.us: ; preds = %for.body388.us
- %inc419.us = add nsw i32 %jj223.34329.us, 1
- %cmp387.us = icmp slt i32 %inc419.us, %add17
- br i1 %cmp387.us, label %for.body388.us, label %for.cond386.for.end421_crit_edge.us
-
-for.cond386.for.end421_crit_edge.us: ; preds = %for.inc418.us
- %add422.us = add nsw i32 %kstart225.54336.us, %stride226.54337.us
- %dec423.us = add nsw i32 %stride226.54337.us, -1
- %indvars.iv.next4992.us = add nsw i64 %indvars.iv4991.us, 1
- br label %for.body381.us
-
-sw.epilog2454: ; preds = %for.cond372.preheader, %if.else319, %sw.bb213, %if.end12
- ret i32 0
-}
-
-declare double @llvm.fabs.f64(double)
-declare dso_local double @Zabs(double) local_unnamed_addr
-declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg)
-
More information about the llvm-commits
mailing list