[llvm] 85eb8b7 - [IndVars] Add test for crash exposed by D114650.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 22 02:44:49 PDT 2022
Author: Florian Hahn
Date: 2022-04-22T10:44:29+01:00
New Revision: 85eb8b7244b6c35653e481049b8f6595ff1e5f40
URL: https://github.com/llvm/llvm-project/commit/85eb8b7244b6c35653e481049b8f6595ff1e5f40
DIFF: https://github.com/llvm/llvm-project/commit/85eb8b7244b6c35653e481049b8f6595ff1e5f40.diff
LOG: [IndVars] Add test for crash exposed by D114650.
Added:
llvm/test/Transforms/IndVarSimplify/phi-select.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/Transforms/IndVarSimplify/phi-select.ll b/llvm/test/Transforms/IndVarSimplify/phi-select.ll
new file mode 100644
index 0000000000000..daa2888fd5104
--- /dev/null
+++ b/llvm/test/Transforms/IndVarSimplify/phi-select.ll
@@ -0,0 +1,51 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -passes=indvars -S %s | FileCheck %s
+
+define void @test_phi_select() {
+; CHECK-LABEL: @test_phi_select(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[OUTER_HEADER:%.*]]
+; CHECK: outer.header:
+; CHECK-NEXT: br i1 false, label [[THEN:%.*]], label [[MERGE:%.*]]
+; CHECK: then:
+; CHECK-NEXT: br label [[MERGE]]
+; CHECK: merge:
+; CHECK-NEXT: br label [[INNER:%.*]]
+; CHECK: inner:
+; CHECK-NEXT: [[INNER_IV_NEXT:%.*]] = add nsw i64 0, 0
+; CHECK-NEXT: br i1 false, label [[INNER]], label [[OUTER_LATCH:%.*]]
+; CHECK: outer.latch:
+; CHECK-NEXT: br i1 true, label [[EXIT:%.*]], label [[OUTER_HEADER]]
+; CHECK: exit:
+; CHECK-NEXT: ret void
+;
+entry:
+ br label %outer.header
+
+outer.header:
+ %iv = phi i64 [ 0, %entry ], [ %iv.next, %outer.latch ]
+ %iv.next.1 = add nsw i64 %iv, 1
+ %cmp.0 = icmp sgt i64 %iv, 50
+ br i1 %cmp.0, label %then, label %merge
+
+then:
+ br label %merge
+
+merge:
+ %iv.sel = phi i64 [ %iv, %outer.header ], [ %iv.next.1, %then ]
+ br label %inner
+
+inner: ; preds = %inner, %outer.header.new
+ %inner.iv = phi i64 [ %iv.sel, %merge ], [ 0, %inner ]
+ %inner.iv.next = add nsw i64 0, 0
+ %ec.1 = icmp sgt i64 0, 0
+ br i1 %ec.1, label %inner, label %outer.latch
+
+outer.latch:
+ %iv.next = add nuw nsw i64 %iv, 1
+ %ec.2 = icmp ult i64 %iv.next, 1000
+ br i1 %ec.2, label %exit, label %outer.header
+
+exit:
+ ret void
+}
More information about the llvm-commits
mailing list