[SimplifyCFG] auto-generate better checks; NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287954 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Sanjay Patel 2016-11-25 21:12:39 +00:00
parent 0ff16e15b4
commit f5c0d7f193
2 changed files with 30 additions and 12 deletions

View File

@ -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
}

View File

@ -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
}