[llvm] 02ab87f - [SimplifyCFG] Add additional jump threading test (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 5 04:58:09 PDT 2022
Author: Nikita Popov
Date: 2022-07-05T13:57:58+02:00
New Revision: 02ab87f54305a4f8b741596538c70d7953440971
URL: https://github.com/llvm/llvm-project/commit/02ab87f54305a4f8b741596538c70d7953440971
DIFF: https://github.com/llvm/llvm-project/commit/02ab87f54305a4f8b741596538c70d7953440971.diff
LOG: [SimplifyCFG] Add additional jump threading test (NFC)
A case where multiple predecessors can be threaded over the same
edge, with a phi node in the threaded block.
Added:
Modified:
llvm/test/Transforms/SimplifyCFG/jump-threading.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/SimplifyCFG/jump-threading.ll b/llvm/test/Transforms/SimplifyCFG/jump-threading.ll
index 59195660a392..a9191b3c61d9 100644
--- a/llvm/test/Transforms/SimplifyCFG/jump-threading.ll
+++ b/llvm/test/Transforms/SimplifyCFG/jump-threading.ll
@@ -4,6 +4,7 @@
declare void @foo()
declare void @bar()
declare void @use.i1(i1)
+declare void @use.i32(i32)
define void @test_phi_simple(i1 %c) {
; CHECK-LABEL: @test_phi_simple(
@@ -262,3 +263,47 @@ else2:
join2:
ret void
}
+
+define void @test_multiple_threadable_preds_with_phi(i1 %cond1, i1 %cond2) {
+; CHECK-LABEL: @test_multiple_threadable_preds_with_phi(
+; CHECK-NEXT: br i1 [[COND1:%.*]], label [[IF1:%.*]], label [[IF2:%.*]]
+; CHECK: if1:
+; CHECK-NEXT: call void @foo()
+; CHECK-NEXT: br i1 [[COND2:%.*]], label [[IF3_CRITEDGE1:%.*]], label [[EXIT:%.*]]
+; CHECK: if2:
+; CHECK-NEXT: call void @bar()
+; CHECK-NEXT: br i1 [[COND2]], label [[IF3_CRITEDGE:%.*]], label [[EXIT]]
+; CHECK: if3.critedge:
+; CHECK-NEXT: call void @use.i32(i32 2)
+; CHECK-NEXT: br label [[IF3:%.*]]
+; CHECK: if3.critedge1:
+; CHECK-NEXT: call void @use.i32(i32 1)
+; CHECK-NEXT: br label [[IF3]]
+; CHECK: if3:
+; CHECK-NEXT: call void @foo()
+; CHECK-NEXT: br label [[EXIT]]
+; CHECK: exit:
+; CHECK-NEXT: ret void
+;
+ br i1 %cond1, label %if1, label %if2
+
+if1:
+ call void @foo()
+ br i1 %cond2, label %join, label %exit
+
+if2:
+ call void @bar()
+ br i1 %cond2, label %join, label %exit
+
+join:
+ %phi = phi i32 [ 1, %if1 ], [ 2, %if2 ]
+ call void @use.i32(i32 %phi)
+ br i1 %cond2, label %if3, label %exit
+
+if3:
+ call void @foo()
+ br label %exit
+
+exit:
+ ret void
+}
More information about the llvm-commits
mailing list