[llvm] fd86d67 - [JumpThreading] Add a test that duplicates insts of a basic block with cond br to preds; NFC
Juneyoung Lee via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 5 17:51:34 PDT 2020
Author: Juneyoung Lee
Date: 2020-08-06T09:19:23+09:00
New Revision: fd86d67b82830f1365e1e25fd138832b475bc1e7
URL: https://github.com/llvm/llvm-project/commit/fd86d67b82830f1365e1e25fd138832b475bc1e7
DIFF: https://github.com/llvm/llvm-project/commit/fd86d67b82830f1365e1e25fd138832b475bc1e7.diff
LOG: [JumpThreading] Add a test that duplicates insts of a basic block with cond br to preds; NFC
Added:
llvm/test/Transforms/JumpThreading/phi-copy-to-pred.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/Transforms/JumpThreading/phi-copy-to-pred.ll b/llvm/test/Transforms/JumpThreading/phi-copy-to-pred.ll
new file mode 100644
index 000000000000..9d16b447f9fb
--- /dev/null
+++ b/llvm/test/Transforms/JumpThreading/phi-copy-to-pred.ll
@@ -0,0 +1,71 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -jump-threading -S < %s | FileCheck %s
+
+declare void @f()
+declare void @g()
+declare void @h()
+
+define i32 @test(i1 %cond, i1 %a, i1 %b) {
+; CHECK-LABEL: @test(
+; CHECK-NEXT: br i1 [[COND:%.*]], label [[A:%.*]], label [[C:%.*]]
+; CHECK: A:
+; CHECK-NEXT: call void @f()
+; CHECK-NEXT: br i1 [[A:%.*]], label [[EXIT1:%.*]], label [[EXIT2:%.*]]
+; CHECK: C:
+; CHECK-NEXT: call void @g()
+; CHECK-NEXT: br i1 [[B:%.*]], label [[EXIT1]], label [[EXIT2]]
+; CHECK: EXIT1:
+; CHECK-NEXT: ret i32 0
+; CHECK: EXIT2:
+; CHECK-NEXT: ret i32 1
+;
+ br i1 %cond, label %A, label %B
+A:
+ call void @f()
+ br label %C
+B:
+ call void @g()
+ br label %C
+C:
+ %p = phi i1 [%a, %A], [%b, %B] ; Check that this is removed
+ br i1 %p, label %EXIT1, label %EXIT2
+EXIT1:
+ ret i32 0
+EXIT2:
+ ret i32 1
+}
+
+define i32 @test2(i1 %cond, i1 %a, i1 %b) {
+; CHECK-LABEL: @test2(
+; CHECK-NEXT: br i1 [[COND:%.*]], label [[A:%.*]], label [[B:%.*]]
+; CHECK: A:
+; CHECK-NEXT: call void @f()
+; CHECK-NEXT: br label [[C:%.*]]
+; CHECK: B:
+; CHECK-NEXT: call void @g()
+; CHECK-NEXT: br label [[C]]
+; CHECK: C:
+; CHECK-NEXT: [[P:%.*]] = phi i1 [ [[A:%.*]], [[A]] ], [ [[B:%.*]], [[B]] ]
+; CHECK-NEXT: [[P_FR:%.*]] = freeze i1 [[P]]
+; CHECK-NEXT: br i1 [[P_FR]], label [[EXIT1:%.*]], label [[EXIT2:%.*]]
+; CHECK: EXIT1:
+; CHECK-NEXT: ret i32 0
+; CHECK: EXIT2:
+; CHECK-NEXT: ret i32 1
+;
+ br i1 %cond, label %A, label %B
+A:
+ call void @f()
+ br label %C
+B:
+ call void @g()
+ br label %C
+C:
+ %p = phi i1 [%a, %A], [%b, %B] ; Check that this is removed
+ %p.fr = freeze i1 %p
+ br i1 %p.fr, label %EXIT1, label %EXIT2
+EXIT1:
+ ret i32 0
+EXIT2:
+ ret i32 1
+}
More information about the llvm-commits
mailing list