blob: 0562b565ae2714211aaafae1c1583b40896769f8 [file] [edit]
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
; RUN: opt < %s -passes="simplifycfg<sink-common-insts>" -S | FileCheck %s
define ptr @test(i16 %0, ptr %p) !prof !0 {
; CHECK-LABEL: define ptr @test(
; CHECK-SAME: i16 [[TMP0:%.*]], ptr [[P:%.*]]) !prof [[PROF0:![0-9]+]] {
; CHECK-NEXT: [[ENTRY:.*]]:
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i16 [[TMP0]], 0
; CHECK-NEXT: br i1 [[TMP1]], label %[[BBL1:.*]], label %[[COMMON_RET:.*]], !prof [[PROF1:![0-9]+]]
; CHECK: [[COMMON_RET]]:
; CHECK-NEXT: [[COMMON_RET_OP:%.*]] = phi ptr [ [[LOAD1:%.*]], %[[BBL1]] ], [ null, %[[ENTRY]] ]
; CHECK-NEXT: ret ptr [[COMMON_RET_OP]]
; CHECK: [[BBL1]]:
; CHECK-NEXT: [[LOAD1]] = load ptr, ptr [[P]], align 8
; CHECK-NEXT: br label %[[COMMON_RET]]
;
entry:
%cmp.i1 = icmp eq i16 %0, 0
%cmp.i2 = icmp eq i16 %0, 0
%or1 = or i1 %cmp.i1, %cmp.i2
br i1 %or1, label %bbl1, label %bbl2, !prof !1
bbl1:
%load1 = load ptr, ptr %p, align 8
ret ptr %load1
bbl2:
ret ptr null
}
define i32 @test2(i1 %cond, i1 %sel_c, i32 %a, i32 %b) !prof !0 {
; CHECK-LABEL: define i32 @test2(
; CHECK-SAME: i1 [[COND:%.*]], i1 [[SEL_C:%.*]], i32 [[A:%.*]], i32 [[B:%.*]]) !prof [[PROF0]] {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[V1:%.*]] = select i1 [[SEL_C]], i32 [[A]], i32 [[B]], !prof [[PROF1]]
; CHECK-NEXT: ret i32 [[V1]]
;
entry:
br i1 %cond, label %if.true, label %if.false
if.true:
%v1 = select i1 %sel_c, i32 %a, i32 %b, !prof !2
ret i32 %v1
if.false:
%v2 = select i1 %sel_c, i32 %a, i32 %b, !prof !3
ret i32 %v2
}
define i32 @test3(i1 %c, i1 %s, i32 %a, i32 %b) !prof !0 {
; CHECK-LABEL: define i32 @test3(
; CHECK-SAME: i1 [[C:%.*]], i1 [[S:%.*]], i32 [[A:%.*]], i32 [[B:%.*]]) !prof [[PROF0]] {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[DOT:%.*]] = select i1 [[C]], i32 1, i32 2
; CHECK-NEXT: [[X2:%.*]] = add i32 [[A]], [[DOT]]
; CHECK-NEXT: [[V2:%.*]] = select i1 [[S]], i32 [[X2]], i32 [[B]], !prof [[PROF1]]
; CHECK-NEXT: ret i32 [[V2]]
;
entry:
br i1 %c, label %then, label %else
then:
%x1 = add i32 %a, 1
%v1 = select i1 %s, i32 %x1, i32 %b, !prof !2
br label %end
else:
%x2 = add i32 %a, 2
%v2 = select i1 %s, i32 %x2, i32 %b, !prof !3
br label %end
end:
%res = phi i32 [ %v1, %then ], [ %v2, %else ]
ret i32 %res
}
!0 = !{!"function_entry_count", i32 62163}
!1 = !{!"unknown", !"simple-loop-unswitch"}
!2 = !{!"branch_weights", i32 2, i32 3}
!3 = !{!"branch_weights", i32 5, i32 7}
;.
; CHECK: [[PROF0]] = !{!"function_entry_count", i32 62163}
; CHECK: [[PROF1]] = !{!"unknown", !"simplifycfg"}
;.