[llvm] 0e67a68 - [SCEV] Add tests for PR66066 (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 15 04:53:40 PDT 2023
Author: Nikita Popov
Date: 2023-09-15T13:53:11+02:00
New Revision: 0e67a68478122be44cec2e5182ba18f719320c0a
URL: https://github.com/llvm/llvm-project/commit/0e67a68478122be44cec2e5182ba18f719320c0a
DIFF: https://github.com/llvm/llvm-project/commit/0e67a68478122be44cec2e5182ba18f719320c0a.diff
LOG: [SCEV] Add tests for PR66066 (NFC)
Added:
llvm/test/Transforms/IndVarSimplify/pr66066.ll
Modified:
llvm/test/Analysis/ScalarEvolution/nsw.ll
Removed:
################################################################################
diff --git a/llvm/test/Analysis/ScalarEvolution/nsw.ll b/llvm/test/Analysis/ScalarEvolution/nsw.ll
index 4f554ef074f768b..ac02036d2ece614 100644
--- a/llvm/test/Analysis/ScalarEvolution/nsw.ll
+++ b/llvm/test/Analysis/ScalarEvolution/nsw.ll
@@ -439,6 +439,40 @@ return:
ret void
}
+; FIXME: {-128,+,-128} should not be <nsw>.
+define void @pr66066() {
+; CHECK-LABEL: 'pr66066'
+; CHECK-NEXT: Classifying expressions for: @pr66066
+; CHECK-NEXT: %iv = phi i8 [ 1, %entry ], [ %iv.dec, %loop ]
+; CHECK-NEXT: --> {1,+,-1}<nsw><%loop> U: [0,2) S: [0,2) Exits: 0 LoopDispositions: { %loop: Computable }
+; 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: 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
+; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is 1
+; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is 1
+; CHECK-NEXT: Predicates:
+; CHECK: Loop %loop: Trip multiple is 2
+;
+entry:
+ br label %loop
+
+loop:
+ %iv = phi i8 [ 1, %entry ], [ %iv.dec, %loop ]
+ %iv.dec = add i8 %iv, -1
+ %shl = shl i8 %iv, 7
+ %cmp1 = icmp eq i8 %shl, 0
+ br i1 %cmp1, label %exit, label %loop
+
+exit:
+ ret void
+}
+
+declare void @print(i32)
+
declare void @foo(i32)
declare i1 @cond()
diff --git a/llvm/test/Transforms/IndVarSimplify/pr66066.ll b/llvm/test/Transforms/IndVarSimplify/pr66066.ll
new file mode 100644
index 000000000000000..c88ca5ed639e2e3
--- /dev/null
+++ b/llvm/test/Transforms/IndVarSimplify/pr66066.ll
@@ -0,0 +1,33 @@
+; 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.
+define void @test() {
+; CHECK-LABEL: define void @test() {
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[LOOP:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: [[IV:%.*]] = phi i8 [ 1, [[ENTRY:%.*]] ], [ [[IV_DEC:%.*]], [[LOOP]] ]
+; 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: exit:
+; CHECK-NEXT: ret void
+;
+entry:
+ br label %loop
+
+loop:
+ %iv = phi i8 [ 1, %entry ], [ %iv.dec, %loop ]
+ %iv.dec = add i8 %iv, -1
+ %shl = shl i8 %iv, 7
+ call void @use(i8 %shl)
+ %cmp1 = icmp eq i8 %shl, 0
+ br i1 %cmp1, label %exit, label %loop
+
+exit:
+ ret void
+}
+
+declare void @use(i32)
More information about the llvm-commits
mailing list