[llvm] eae6bb3 - [SCCP] Add multi-edge switch + phi test case (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 22 11:28:32 PDT 2020


Author: Nikita Popov
Date: 2020-07-22T20:28:22+02:00
New Revision: eae6bb3807977a2998ac9114a1d6ecb6bdafc3cd

URL: https://github.com/llvm/llvm-project/commit/eae6bb3807977a2998ac9114a1d6ecb6bdafc3cd
DIFF: https://github.com/llvm/llvm-project/commit/eae6bb3807977a2998ac9114a1d6ecb6bdafc3cd.diff

LOG: [SCCP] Add multi-edge switch + phi test case (NFC)

Added: 
    

Modified: 
    llvm/test/Transforms/SCCP/switch.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/SCCP/switch.ll b/llvm/test/Transforms/SCCP/switch.ll
index fc329c2628eb..1d9c12b5c675 100644
--- a/llvm/test/Transforms/SCCP/switch.ll
+++ b/llvm/test/Transforms/SCCP/switch.ll
@@ -18,6 +18,38 @@ d:
   ret void
 }
 
+define i32 @test_duplicate_successors_phi(i1 %c, i32 %x) {
+; CHECK-LABEL: @test_duplicate_successors_phi(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    br i1 [[C:%.*]], label [[SWITCH:%.*]], label [[END:%.*]]
+; CHECK:       switch:
+; CHECK-NEXT:    switch i32 -1, label [[SWITCH_DEFAULT:%.*]] [
+; CHECK-NEXT:    i32 0, label [[END]]
+; CHECK-NEXT:    i32 1, label [[END]]
+; CHECK-NEXT:    ]
+; CHECK:       switch.default:
+; CHECK-NEXT:    ret i32 -1
+; CHECK:       end:
+; CHECK-NEXT:    [[PHI:%.*]] = phi i32 [ [[X:%.*]], [[ENTRY:%.*]] ], [ 1, [[SWITCH]] ], [ 1, [[SWITCH]] ]
+; CHECK-NEXT:    ret i32 [[PHI]]
+;
+entry:
+  br i1 %c, label %switch, label %end
+
+switch:
+  switch i32 -1, 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