[llvm] fb2627d - [Test] Add test showing that SCEV cannot compute IV's range
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 13 03:53:01 PDT 2020
Author: Max Kazantsev
Date: 2020-10-13T17:52:39+07:00
New Revision: fb2627d8d21574a0d1a81596d00953075265ac88
URL: https://github.com/llvm/llvm-project/commit/fb2627d8d21574a0d1a81596d00953075265ac88
DIFF: https://github.com/llvm/llvm-project/commit/fb2627d8d21574a0d1a81596d00953075265ac88.diff
LOG: [Test] Add test showing that SCEV cannot compute IV's range
Added:
llvm/test/Analysis/ScalarEvolution/no-wrap-symbolic-becount.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/Analysis/ScalarEvolution/no-wrap-symbolic-becount.ll b/llvm/test/Analysis/ScalarEvolution/no-wrap-symbolic-becount.ll
new file mode 100644
index 000000000000..f9cb89c97161
--- /dev/null
+++ b/llvm/test/Analysis/ScalarEvolution/no-wrap-symbolic-becount.ll
@@ -0,0 +1,58 @@
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
+; RUN: opt < %s -S -analyze -scalar-evolution | FileCheck %s
+
+define i32 @test_01(i32 %start, i32* %p, i32* %q) {
+; CHECK-LABEL: 'test_01'
+; CHECK-NEXT: Classifying expressions for: @test_01
+; CHECK-NEXT: %0 = zext i32 %start to i64
+; CHECK-NEXT: --> (zext i32 %start to i64) U: [0,4294967296) S: [0,4294967296)
+; CHECK-NEXT: %indvars.iv = phi i64 [ %indvars.iv.next, %backedge ], [ %0, %entry ]
+; CHECK-NEXT: --> {(zext i32 %start to i64),+,-1}<nsw><%loop> U: [-4294967295,4294967296) S: [-4294967295,4294967296) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: %iv = phi i32 [ %start, %entry ], [ %iv.next, %backedge ]
+; CHECK-NEXT: --> {%start,+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: %iv.next = add i32 %iv, -1
+; CHECK-NEXT: --> {(-1 + %start),+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: %index = zext i32 %iv.next to i64
+; CHECK-NEXT: --> (zext i32 {(-1 + %start),+,-1}<%loop> to i64) U: [0,4294967296) S: [0,4294967296) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: %store.addr = getelementptr i32, i32* %p, i64 %index
+; CHECK-NEXT: --> ((4 * (zext i32 {(-1 + %start),+,-1}<%loop> to i64))<nuw><nsw> + %p) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: %load.addr = getelementptr i32, i32* %q, i64 %index
+; CHECK-NEXT: --> ((4 * (zext i32 {(-1 + %start),+,-1}<%loop> to i64))<nuw><nsw> + %q) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: %stop = load i32, i32* %load.addr, align 4
+; CHECK-NEXT: --> %stop U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
+; CHECK-NEXT: %indvars.iv.next = add nsw i64 %indvars.iv, -1
+; CHECK-NEXT: --> {(-1 + (zext i32 %start to i64))<nsw>,+,-1}<nsw><%loop> U: [-4294967296,4294967295) S: [-4294967296,4294967295) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT: Determining loop execution counts for: @test_01
+; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
+; CHECK-NEXT: exit count for loop: (zext i32 %start to i64)
+; CHECK-NEXT: exit count for backedge: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: Loop %loop: max backedge-taken count is 4294967295
+; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
+;
+entry:
+ %0 = zext i32 %start to i64
+ br label %loop
+
+loop: ; preds = %backedge, %entry
+ %indvars.iv = phi i64 [ %indvars.iv.next, %backedge ], [ %0, %entry ]
+ %iv = phi i32 [ %start, %entry ], [ %iv.next, %backedge ]
+ %cond = icmp eq i64 %indvars.iv, 0
+ br i1 %cond, label %exit, label %backedge
+
+backedge: ; preds = %loop
+ %iv.next = add i32 %iv, -1
+ %index = zext i32 %iv.next to i64
+ %store.addr = getelementptr i32, i32* %p, i64 %index
+ store i32 1, i32* %store.addr, align 4
+ %load.addr = getelementptr i32, i32* %q, i64 %index
+ %stop = load i32, i32* %load.addr, align 4
+ %loop.cond = icmp eq i32 %stop, 0
+ %indvars.iv.next = add nsw i64 %indvars.iv, -1
+ br i1 %loop.cond, label %loop, label %failure
+
+exit: ; preds = %loop
+ ret i32 0
+
+failure: ; preds = %backedge
+ unreachable
+}
More information about the llvm-commits
mailing list