[llvm] r287954 - [SimplifyCFG] auto-generate better checks; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 25 13:12:39 PST 2016


Author: spatel
Date: Fri Nov 25 15:12:39 2016
New Revision: 287954

URL: http://llvm.org/viewvc/llvm-project?rev=287954&view=rev
Log:
[SimplifyCFG] auto-generate better checks; NFC

Modified:
    llvm/trunk/test/Transforms/SimplifyCFG/switch-to-select-multiple-edge-per-block-phi.ll
    llvm/trunk/test/Transforms/SimplifyCFG/switch-to-select-two-case.ll

Modified: llvm/trunk/test/Transforms/SimplifyCFG/switch-to-select-multiple-edge-per-block-phi.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/switch-to-select-multiple-edge-per-block-phi.ll?rev=287954&r1=287953&r2=287954&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SimplifyCFG/switch-to-select-multiple-edge-per-block-phi.ll (original)
+++ llvm/trunk/test/Transforms/SimplifyCFG/switch-to-select-multiple-edge-per-block-phi.ll Fri Nov 25 15:12:39 2016
@@ -16,9 +16,22 @@
 
 ; Function Attrs: nounwind
 define i32 @fn1() {
-; CHECK-LABEL: @fn1
-; CHECK: %switch.selectcmp1 = icmp eq i32 %1, 5
-; CHECK: %switch.select2 = select i1 %switch.selectcmp1, i32 5, i32 %switch.select
+; CHECK-LABEL: @fn1(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[TMP0:%.*]] = load i32, i32* @b, align 4
+; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp eq i32 [[TMP0]], 0
+; CHECK-NEXT:    br i1 [[TOBOOL]], label %return, label %if.then
+; CHECK:       if.then:
+; CHECK-NEXT:    [[TMP1:%.*]] = load i32, i32* @a, align 4
+; CHECK-NEXT:    [[SWITCH_SELECTCMP:%.*]] = icmp eq i32 [[TMP1]], 0
+; CHECK-NEXT:    [[SWITCH_SELECT:%.*]] = select i1 [[SWITCH_SELECTCMP:%.*]], i32 0, i32 0
+; CHECK-NEXT:    [[SWITCH_SELECTCMP1:%.*]] = icmp eq i32 [[TMP1]], 5
+; CHECK-NEXT:    [[SWITCH_SELECT2:%.*]] = select i1 [[SWITCH_SELECTCMP1]], i32 5, i32 [[SWITCH_SELECT]]
+; CHECK-NEXT:    br label %return
+; CHECK:       return:
+; CHECK-NEXT:    [[RETVAL_0:%.*]] = phi i32 [ [[SWITCH_SELECT2]], %if.then ], [ 0, %entry ]
+; CHECK-NEXT:    ret i32 [[RETVAL_0]]
+;
 entry:
   %0 = load i32, i32* @b, align 4
   %tobool = icmp eq i32 %0, 0
@@ -27,8 +40,8 @@ entry:
 if.then:
   %1 = load i32, i32* @a, align 4
   switch i32 %1, label %if.end3 [
-    i32 5, label %return
-    i32 0, label %return
+  i32 5, label %return
+  i32 0, label %return
   ]
 
 if.end3:
@@ -38,3 +51,4 @@ return:
   %retval.0 = phi i32 [ 0, %if.end3 ], [ %1, %if.then ], [ %1, %if.then ]
   ret i32 %retval.0
 }
+

Modified: llvm/trunk/test/Transforms/SimplifyCFG/switch-to-select-two-case.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/switch-to-select-two-case.ll?rev=287954&r1=287953&r2=287954&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SimplifyCFG/switch-to-select-two-case.ll (original)
+++ llvm/trunk/test/Transforms/SimplifyCFG/switch-to-select-two-case.ll Fri Nov 25 15:12:39 2016
@@ -11,15 +11,18 @@
 ; }
 
 define i32 @foo1_with_default(i32 %a) {
-; CHECK-LABEL: @foo1_with_default
-; CHECK: %switch.selectcmp = icmp eq i32 %a, 20
-; CHECK-NEXT: %switch.select = select i1 %switch.selectcmp, i32 2, i32 4
-; CHECK-NEXT: %switch.selectcmp1 = icmp eq i32 %a, 10
-; CHECK-NEXT: %switch.select2 = select i1 %switch.selectcmp1, i32 10, i32 %switch.select
+; CHECK-LABEL: @foo1_with_default(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[SWITCH_SELECTCMP:%.*]] = icmp eq i32 %a, 20
+; CHECK-NEXT:    [[SWITCH_SELECT:%.*]] = select i1 [[SWITCH_SELECTCMP:%.*]], i32 2, i32 4
+; CHECK-NEXT:    [[SWITCH_SELECTCMP1:%.*]] = icmp eq i32 %a, 10
+; CHECK-NEXT:    [[SWITCH_SELECT2:%.*]] = select i1 [[SWITCH_SELECTCMP1]], i32 10, i32 [[SWITCH_SELECT]]
+; CHECK-NEXT:    ret i32 [[SWITCH_SELECT2]]
+;
 entry:
   switch i32 %a, label %sw.epilog [
-    i32 10, label %sw.bb
-    i32 20, label %sw.bb1
+  i32 10, label %sw.bb
+  i32 20, label %sw.bb1
   ]
 
 sw.bb:
@@ -35,3 +38,4 @@ return:
   %retval.0 = phi i32 [ 4, %sw.epilog ], [ 2, %sw.bb1 ], [ 10, %sw.bb ]
   ret i32 %retval.0
 }
+




More information about the llvm-commits mailing list