[llvm] e20b307 - [SCCP] Add additional multi-edge + phi tests (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 22 13:10:39 PDT 2020
Author: Nikita Popov
Date: 2020-07-22T22:10:23+02:00
New Revision: e20b3079c14d8e68ebc90125eb95156f2e1ee9e4
URL: https://github.com/llvm/llvm-project/commit/e20b3079c14d8e68ebc90125eb95156f2e1ee9e4
DIFF: https://github.com/llvm/llvm-project/commit/e20b3079c14d8e68ebc90125eb95156f2e1ee9e4.diff
LOG: [SCCP] Add additional multi-edge + phi tests (NFC)
Added:
Modified:
llvm/test/Transforms/SCCP/indirectbr.ll
llvm/test/Transforms/SCCP/switch.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/SCCP/indirectbr.ll b/llvm/test/Transforms/SCCP/indirectbr.ll
index 8953e4003292..6889282e3874 100644
--- a/llvm/test/Transforms/SCCP/indirectbr.ll
+++ b/llvm/test/Transforms/SCCP/indirectbr.ll
@@ -140,3 +140,27 @@ define i32 @indbrtest5_callee(i1 %c) {
%r = call i32 @indbrtest5(i1 %c)
ret i32 %r
}
+
+define i32 @indbr_duplicate_successors_phi(i1 %c, i32 %x) {
+; CHECK-LABEL: @indbr_duplicate_successors_phi(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br i1 [[C:%.*]], label [[INDBR:%.*]], label [[BB0:%.*]]
+; CHECK: indbr:
+; CHECK-NEXT: br label [[BB0]]
+; CHECK: BB0:
+; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ [[X:%.*]], [[ENTRY:%.*]] ], [ 0, [[INDBR]] ]
+; CHECK-NEXT: ret i32 [[PHI]]
+;
+entry:
+ br i1 %c, label %indbr, label %BB0
+
+indbr:
+ indirectbr i8* blockaddress(@indbr_duplicate_successors_phi, %BB0), [label %BB0, label %BB0, label %BB1]
+
+BB0:
+ %phi = phi i32 [ %x, %entry ], [ 0, %indbr ], [ 0, %indbr ]
+ ret i32 %phi
+
+BB1:
+ ret i32 0
+}
diff --git a/llvm/test/Transforms/SCCP/switch.ll b/llvm/test/Transforms/SCCP/switch.ll
index 1d9c12b5c675..d895c5629cd4 100644
--- a/llvm/test/Transforms/SCCP/switch.ll
+++ b/llvm/test/Transforms/SCCP/switch.ll
@@ -50,6 +50,33 @@ end:
ret i32 %phi
}
+define i32 @test_duplicate_successors_phi_2(i1 %c, i32 %x) {
+; CHECK-LABEL: @test_duplicate_successors_phi_2(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br i1 [[C:%.*]], label [[SWITCH:%.*]], label [[END:%.*]]
+; CHECK: switch:
+; CHECK-NEXT: br label [[END]]
+; CHECK: end:
+; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ [[X:%.*]], [[ENTRY:%.*]] ], [ 1, [[SWITCH]] ]
+; CHECK-NEXT: ret i32 [[PHI]]
+;
+entry:
+ br i1 %c, label %switch, label %end
+
+switch:
+ switch i32 0, label %switch.default [
+ i32 0, label %end
+ i32 1, label %end
+ ]
+
+switch.default:
+ ret i32 -1
+
+end:
+ %phi = phi i32 [ %x, %entry ], [ 1, %switch ], [ 1, %switch ]
+ ret i32 %phi
+}
+
define i32 @test_local_range(i32 %x) {
; CHECK-LABEL: @test_local_range(
; CHECK-NEXT: [[C:%.*]] = icmp ult i32 [[X:%.*]], 3
More information about the llvm-commits
mailing list