[llvm] 5555252 - [InstCombine] Add additional test for phi to switch cond fold (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 2 05:33:25 PST 2022
Author: Nikita Popov
Date: 2022-03-02T14:33:15+01:00
New Revision: 5555252b5249993c96be013856c28b6c7ff6fa0e
URL: https://github.com/llvm/llvm-project/commit/5555252b5249993c96be013856c28b6c7ff6fa0e
DIFF: https://github.com/llvm/llvm-project/commit/5555252b5249993c96be013856c28b6c7ff6fa0e.diff
LOG: [InstCombine] Add additional test for phi to switch cond fold (NFC)
This test exposes a bug in the edge dominance implementation.
Added:
Modified:
llvm/test/Transforms/InstCombine/simple_phi_condition.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/simple_phi_condition.ll b/llvm/test/Transforms/InstCombine/simple_phi_condition.ll
index a247a2e0b5305..517a79d677ff9 100644
--- a/llvm/test/Transforms/InstCombine/simple_phi_condition.ll
+++ b/llvm/test/Transforms/InstCombine/simple_phi_condition.ll
@@ -345,6 +345,40 @@ merge:
ret i8 %ret
}
+define i8 @test_switch_duplicate_direct_edge(i8 %cond) {
+; CHECK-LABEL: @test_switch_duplicate_direct_edge(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: switch i8 [[COND:%.*]], label [[DEFAULT:%.*]] [
+; CHECK-NEXT: i8 1, label [[SW_1:%.*]]
+; CHECK-NEXT: i8 7, label [[MERGE:%.*]]
+; CHECK-NEXT: i8 19, label [[MERGE]]
+; CHECK-NEXT: ]
+; CHECK: sw.1:
+; CHECK-NEXT: br label [[MERGE]]
+; CHECK: default:
+; CHECK-NEXT: ret i8 42
+; CHECK: merge:
+; CHECK-NEXT: [[RET:%.*]] = phi i8 [ 1, [[SW_1]] ], [ 7, [[ENTRY:%.*]] ], [ 7, [[ENTRY]] ]
+; CHECK-NEXT: ret i8 [[RET]]
+;
+entry:
+ switch i8 %cond, label %default [
+ i8 1, label %sw.1
+ i8 7, label %merge
+ i8 19, label %merge
+ ]
+
+sw.1:
+ br label %merge
+
+default:
+ ret i8 42
+
+merge:
+ %ret = phi i8 [ 1, %sw.1 ], [ 7, %entry ], [ 7, %entry ]
+ ret i8 %ret
+}
+
define i8 @test_switch_subset(i8 %cond) {
; CHECK-LABEL: @test_switch_subset(
; CHECK-NEXT: entry:
More information about the llvm-commits
mailing list