mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
[NFC][SimplifyCFG] Add more negative tests for profmd-induced speculation avoidance
This commit is contained in:
parent
c0784ed26d
commit
ddc2eed16c
@ -79,20 +79,45 @@ end:
|
||||
ret i32 %res
|
||||
}
|
||||
|
||||
define i32 @unpredictable(i32 %a, i32 %b, i32 %c, i32 %d) {
|
||||
; CHECK-LABEL: @unpredictable(
|
||||
define i32 @almost_predictably_nontaken(i32 %a, i32 %b, i32 %c, i32 %d) {
|
||||
; CHECK-LABEL: @almost_predictably_nontaken(
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: call void @sideeffect0()
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[A:%.*]], [[B:%.*]]
|
||||
; CHECK-NEXT: [[V0:%.*]] = add i32 [[C:%.*]], [[D:%.*]]
|
||||
; CHECK-NEXT: [[RES:%.*]] = select i1 [[CMP]], i32 [[V0]], i32 0, !unpredictable !1
|
||||
; CHECK-NEXT: [[RES:%.*]] = select i1 [[CMP]], i32 0, i32 [[V0]], !prof [[PROF1:![0-9]+]]
|
||||
; CHECK-NEXT: call void @sideeffect1()
|
||||
; CHECK-NEXT: ret i32 [[RES]]
|
||||
;
|
||||
entry:
|
||||
call void @sideeffect0()
|
||||
%cmp = icmp eq i32 %a, %b
|
||||
br i1 %cmp, label %cond.true, label %end, !unpredictable !1 ; unpredictable
|
||||
br i1 %cmp, label %end, label %cond.true, !prof !1 ; probably likely branches to %end
|
||||
|
||||
cond.true:
|
||||
%v0 = add i32 %c, %d
|
||||
br label %end
|
||||
|
||||
end:
|
||||
%res = phi i32 [ %v0, %cond.true ], [ 0, %entry ]
|
||||
call void @sideeffect1()
|
||||
ret i32 %res
|
||||
}
|
||||
|
||||
define i32 @unpredictable(i32 %a, i32 %b, i32 %c, i32 %d) {
|
||||
; CHECK-LABEL: @unpredictable(
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: call void @sideeffect0()
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[A:%.*]], [[B:%.*]]
|
||||
; CHECK-NEXT: [[V0:%.*]] = add i32 [[C:%.*]], [[D:%.*]]
|
||||
; CHECK-NEXT: [[RES:%.*]] = select i1 [[CMP]], i32 [[V0]], i32 0, !unpredictable !2
|
||||
; CHECK-NEXT: call void @sideeffect1()
|
||||
; CHECK-NEXT: ret i32 [[RES]]
|
||||
;
|
||||
entry:
|
||||
call void @sideeffect0()
|
||||
%cmp = icmp eq i32 %a, %b
|
||||
br i1 %cmp, label %cond.true, label %end, !unpredictable !2 ; unpredictable
|
||||
|
||||
cond.true:
|
||||
%v0 = add i32 %c, %d
|
||||
@ -110,14 +135,14 @@ define i32 @unpredictable_yet_taken(i32 %a, i32 %b, i32 %c, i32 %d) {
|
||||
; CHECK-NEXT: call void @sideeffect0()
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[A:%.*]], [[B:%.*]]
|
||||
; CHECK-NEXT: [[V0:%.*]] = add i32 [[C:%.*]], [[D:%.*]]
|
||||
; CHECK-NEXT: [[RES:%.*]] = select i1 [[CMP]], i32 [[V0]], i32 0, !prof [[PROF0]], !unpredictable !1
|
||||
; CHECK-NEXT: [[RES:%.*]] = select i1 [[CMP]], i32 [[V0]], i32 0, !prof [[PROF0]], !unpredictable !2
|
||||
; CHECK-NEXT: call void @sideeffect1()
|
||||
; CHECK-NEXT: ret i32 [[RES]]
|
||||
;
|
||||
entry:
|
||||
call void @sideeffect0()
|
||||
%cmp = icmp eq i32 %a, %b
|
||||
br i1 %cmp, label %cond.true, label %end, !prof !0, !unpredictable !1 ; likely branches to %cond.true, yet unpredictable
|
||||
br i1 %cmp, label %cond.true, label %end, !prof !0, !unpredictable !2 ; likely branches to %cond.true, yet unpredictable
|
||||
|
||||
cond.true:
|
||||
%v0 = add i32 %c, %d
|
||||
@ -135,14 +160,14 @@ define i32 @unpredictable_yet_nontaken(i32 %a, i32 %b, i32 %c, i32 %d) {
|
||||
; CHECK-NEXT: call void @sideeffect0()
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[A:%.*]], [[B:%.*]]
|
||||
; CHECK-NEXT: [[V0:%.*]] = add i32 [[C:%.*]], [[D:%.*]]
|
||||
; CHECK-NEXT: [[RES:%.*]] = select i1 [[CMP]], i32 0, i32 [[V0]], !prof [[PROF0]], !unpredictable !1
|
||||
; CHECK-NEXT: [[RES:%.*]] = select i1 [[CMP]], i32 0, i32 [[V0]], !prof [[PROF0]], !unpredictable !2
|
||||
; CHECK-NEXT: call void @sideeffect1()
|
||||
; CHECK-NEXT: ret i32 [[RES]]
|
||||
;
|
||||
entry:
|
||||
call void @sideeffect0()
|
||||
%cmp = icmp eq i32 %a, %b
|
||||
br i1 %cmp, label %end, label %cond.true, !prof !0, !unpredictable !1 ; likely branches to %end, yet unpredictable
|
||||
br i1 %cmp, label %end, label %cond.true, !prof !0, !unpredictable !2 ; likely branches to %end, yet unpredictable
|
||||
|
||||
cond.true:
|
||||
%v0 = add i32 %c, %d
|
||||
@ -155,7 +180,9 @@ end:
|
||||
}
|
||||
|
||||
!0 = !{!"branch_weights", i32 99, i32 1}
|
||||
!1 = !{}
|
||||
!1 = !{!"branch_weights", i32 70, i32 1}
|
||||
!2 = !{}
|
||||
|
||||
; CHECK: !0 = !{!"branch_weights", i32 99, i32 1}
|
||||
; CHECK: !1 = !{}
|
||||
; CHECK: !1 = !{!"branch_weights", i32 70, i32 1}
|
||||
; CHECK: !2 = !{}
|
||||
|
@ -64,6 +64,36 @@ end:
|
||||
ret i32 %res
|
||||
}
|
||||
|
||||
define i32 @almost_predictably_taken(i32 %a, i32 %b, i32 %c, i32 %d) {
|
||||
; CHECK-LABEL: @almost_predictably_taken(
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: call void @sideeffect0()
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[A:%.*]], [[B:%.*]]
|
||||
; CHECK-NEXT: [[V0:%.*]] = add i32 [[C:%.*]], [[D:%.*]]
|
||||
; CHECK-NEXT: [[V1:%.*]] = sub i32 [[C]], [[D]]
|
||||
; CHECK-NEXT: [[RES:%.*]] = select i1 [[CMP]], i32 [[V0]], i32 [[V1]], !prof [[PROF1:![0-9]+]]
|
||||
; CHECK-NEXT: call void @sideeffect1()
|
||||
; CHECK-NEXT: ret i32 [[RES]]
|
||||
;
|
||||
entry:
|
||||
call void @sideeffect0()
|
||||
%cmp = icmp eq i32 %a, %b
|
||||
br i1 %cmp, label %cond.true, label %cond.false, !prof !1 ; almost likely branches to %cond.true
|
||||
|
||||
cond.true:
|
||||
%v0 = add i32 %c, %d
|
||||
br label %end
|
||||
|
||||
cond.false:
|
||||
%v1 = sub i32 %c, %d
|
||||
br label %end
|
||||
|
||||
end:
|
||||
%res = phi i32 [ %v0, %cond.true ], [ %v1, %cond.false ]
|
||||
call void @sideeffect1()
|
||||
ret i32 %res
|
||||
}
|
||||
|
||||
define i32 @predictably_nontaken(i32 %a, i32 %b, i32 %c, i32 %d) {
|
||||
; CHECK-LABEL: @predictably_nontaken(
|
||||
; CHECK-NEXT: entry:
|
||||
@ -94,6 +124,36 @@ end:
|
||||
ret i32 %res
|
||||
}
|
||||
|
||||
define i32 @almost_predictably_nontaken(i32 %a, i32 %b, i32 %c, i32 %d) {
|
||||
; CHECK-LABEL: @almost_predictably_nontaken(
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: call void @sideeffect0()
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[A:%.*]], [[B:%.*]]
|
||||
; CHECK-NEXT: [[V0:%.*]] = add i32 [[C:%.*]], [[D:%.*]]
|
||||
; CHECK-NEXT: [[V1:%.*]] = sub i32 [[C]], [[D]]
|
||||
; CHECK-NEXT: [[RES:%.*]] = select i1 [[CMP]], i32 [[V1]], i32 [[V0]], !prof [[PROF1]]
|
||||
; CHECK-NEXT: call void @sideeffect1()
|
||||
; CHECK-NEXT: ret i32 [[RES]]
|
||||
;
|
||||
entry:
|
||||
call void @sideeffect0()
|
||||
%cmp = icmp eq i32 %a, %b
|
||||
br i1 %cmp, label %cond.false, label %cond.true, !prof !1 ; probably likely branches to %cond.false
|
||||
|
||||
cond.true:
|
||||
%v0 = add i32 %c, %d
|
||||
br label %end
|
||||
|
||||
cond.false:
|
||||
%v1 = sub i32 %c, %d
|
||||
br label %end
|
||||
|
||||
end:
|
||||
%res = phi i32 [ %v0, %cond.true ], [ %v1, %cond.false ]
|
||||
call void @sideeffect1()
|
||||
ret i32 %res
|
||||
}
|
||||
|
||||
define i32 @unpredictable(i32 %a, i32 %b, i32 %c, i32 %d) {
|
||||
; CHECK-LABEL: @unpredictable(
|
||||
; CHECK-NEXT: entry:
|
||||
@ -101,14 +161,14 @@ define i32 @unpredictable(i32 %a, i32 %b, i32 %c, i32 %d) {
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[A:%.*]], [[B:%.*]]
|
||||
; CHECK-NEXT: [[V0:%.*]] = add i32 [[C:%.*]], [[D:%.*]]
|
||||
; CHECK-NEXT: [[V1:%.*]] = sub i32 [[C]], [[D]]
|
||||
; CHECK-NEXT: [[RES:%.*]] = select i1 [[CMP]], i32 [[V0]], i32 [[V1]], !unpredictable !1
|
||||
; CHECK-NEXT: [[RES:%.*]] = select i1 [[CMP]], i32 [[V0]], i32 [[V1]], !unpredictable !2
|
||||
; CHECK-NEXT: call void @sideeffect1()
|
||||
; CHECK-NEXT: ret i32 [[RES]]
|
||||
;
|
||||
entry:
|
||||
call void @sideeffect0()
|
||||
%cmp = icmp eq i32 %a, %b
|
||||
br i1 %cmp, label %cond.true, label %cond.false, !unpredictable !1 ; unpredictable
|
||||
br i1 %cmp, label %cond.true, label %cond.false, !unpredictable !2 ; unpredictable
|
||||
|
||||
cond.true:
|
||||
%v0 = add i32 %c, %d
|
||||
@ -131,14 +191,14 @@ define i32 @unpredictable_yet_taken(i32 %a, i32 %b, i32 %c, i32 %d) {
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[A:%.*]], [[B:%.*]]
|
||||
; CHECK-NEXT: [[V0:%.*]] = add i32 [[C:%.*]], [[D:%.*]]
|
||||
; CHECK-NEXT: [[V1:%.*]] = sub i32 [[C]], [[D]]
|
||||
; CHECK-NEXT: [[RES:%.*]] = select i1 [[CMP]], i32 [[V0]], i32 [[V1]], !prof [[PROF0]], !unpredictable !1
|
||||
; CHECK-NEXT: [[RES:%.*]] = select i1 [[CMP]], i32 [[V0]], i32 [[V1]], !prof [[PROF0]], !unpredictable !2
|
||||
; CHECK-NEXT: call void @sideeffect1()
|
||||
; CHECK-NEXT: ret i32 [[RES]]
|
||||
;
|
||||
entry:
|
||||
call void @sideeffect0()
|
||||
%cmp = icmp eq i32 %a, %b
|
||||
br i1 %cmp, label %cond.true, label %cond.false, !prof !0, !unpredictable !1 ; likely branches to %cond.true, yet unpredictable
|
||||
br i1 %cmp, label %cond.true, label %cond.false, !prof !0, !unpredictable !2 ; likely branches to %cond.true, yet unpredictable
|
||||
|
||||
cond.true:
|
||||
%v0 = add i32 %c, %d
|
||||
@ -161,14 +221,14 @@ define i32 @unpredictable_yet_nontaken(i32 %a, i32 %b, i32 %c, i32 %d) {
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[A:%.*]], [[B:%.*]]
|
||||
; CHECK-NEXT: [[V0:%.*]] = add i32 [[C:%.*]], [[D:%.*]]
|
||||
; CHECK-NEXT: [[V1:%.*]] = sub i32 [[C]], [[D]]
|
||||
; CHECK-NEXT: [[RES:%.*]] = select i1 [[CMP]], i32 [[V1]], i32 [[V0]], !prof [[PROF0]], !unpredictable !1
|
||||
; CHECK-NEXT: [[RES:%.*]] = select i1 [[CMP]], i32 [[V1]], i32 [[V0]], !prof [[PROF0]], !unpredictable !2
|
||||
; CHECK-NEXT: call void @sideeffect1()
|
||||
; CHECK-NEXT: ret i32 [[RES]]
|
||||
;
|
||||
entry:
|
||||
call void @sideeffect0()
|
||||
%cmp = icmp eq i32 %a, %b
|
||||
br i1 %cmp, label %cond.false, label %cond.true, !prof !0, !unpredictable !1 ; likely branches to %cond.false, yet unpredictable
|
||||
br i1 %cmp, label %cond.false, label %cond.true, !prof !0, !unpredictable !2 ; likely branches to %cond.false, yet unpredictable
|
||||
|
||||
cond.true:
|
||||
%v0 = add i32 %c, %d
|
||||
@ -185,7 +245,9 @@ end:
|
||||
}
|
||||
|
||||
!0 = !{!"branch_weights", i32 99, i32 1}
|
||||
!1 = !{}
|
||||
!1 = !{!"branch_weights", i32 70, i32 1}
|
||||
!2 = !{}
|
||||
|
||||
; CHECK: !0 = !{!"branch_weights", i32 99, i32 1}
|
||||
; CHECK: !1 = !{}
|
||||
; CHECK: !1 = !{!"branch_weights", i32 70, i32 1}
|
||||
; CHECK: !2 = !{}
|
||||
|
@ -728,6 +728,37 @@ exit:
|
||||
ret void
|
||||
}
|
||||
|
||||
|
||||
define void @or_icmps_probably_not_harmful(i32 %x, i32 %y, i8* %p) {
|
||||
; CHECK-LABEL: @or_icmps_probably_not_harmful(
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: [[EXPECTED_TRUE:%.*]] = icmp sgt i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: br i1 [[EXPECTED_TRUE]], label [[EXIT:%.*]], label [[RARE:%.*]], !prof [[PROF19]], !unpredictable !21
|
||||
; CHECK: rare:
|
||||
; CHECK-NEXT: [[EXPENSIVE:%.*]] = icmp eq i32 [[Y:%.*]], 0
|
||||
; CHECK-NEXT: br i1 [[EXPENSIVE]], label [[EXIT]], label [[FALSE:%.*]]
|
||||
; CHECK: false:
|
||||
; CHECK-NEXT: store i8 42, i8* [[P:%.*]], align 1
|
||||
; CHECK-NEXT: br label [[EXIT]]
|
||||
; CHECK: exit:
|
||||
; CHECK-NEXT: ret void
|
||||
;
|
||||
entry:
|
||||
%expected_true = icmp sgt i32 %x, -1
|
||||
br i1 %expected_true, label %exit, label %rare, !prof !15, !unpredictable !20
|
||||
|
||||
rare:
|
||||
%expensive = icmp eq i32 %y, 0
|
||||
br i1 %expensive, label %exit, label %false
|
||||
|
||||
false:
|
||||
store i8 42, i8* %p, align 1
|
||||
br label %exit
|
||||
|
||||
exit:
|
||||
ret void
|
||||
}
|
||||
|
||||
; The probability threshold is determined by a TTI setting.
|
||||
; In this example, we are just short of strongly expected, so speculate.
|
||||
|
||||
@ -737,7 +768,7 @@ define void @or_icmps_not_that_harmful(i32 %x, i32 %y, i8* %p) {
|
||||
; CHECK-NEXT: [[EXPECTED_TRUE:%.*]] = icmp sgt i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[EXPENSIVE:%.*]] = icmp eq i32 [[Y:%.*]], 0
|
||||
; CHECK-NEXT: [[OR_COND:%.*]] = select i1 [[EXPECTED_TRUE]], i1 true, i1 [[EXPENSIVE]]
|
||||
; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof [[PROF21:![0-9]+]]
|
||||
; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof [[PROF22:![0-9]+]]
|
||||
; CHECK: false:
|
||||
; CHECK-NEXT: store i8 42, i8* [[P:%.*]], align 1
|
||||
; CHECK-NEXT: br label [[EXIT]]
|
||||
@ -769,7 +800,7 @@ define void @or_icmps_not_that_harmful_inverted(i32 %x, i32 %y, i8* %p) {
|
||||
; CHECK-NEXT: [[EXPECTED_TRUE:%.*]] = icmp sgt i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[EXPENSIVE:%.*]] = icmp eq i32 [[Y:%.*]], 0
|
||||
; CHECK-NEXT: [[OR_COND:%.*]] = select i1 [[EXPECTED_TRUE]], i1 true, i1 [[EXPENSIVE]]
|
||||
; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof [[PROF22:![0-9]+]]
|
||||
; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof [[PROF23:![0-9]+]]
|
||||
; CHECK: false:
|
||||
; CHECK-NEXT: store i8 42, i8* [[P:%.*]], align 1
|
||||
; CHECK-NEXT: br label [[EXIT]]
|
||||
@ -800,7 +831,7 @@ define void @or_icmps_useful(i32 %x, i32 %y, i8* %p) {
|
||||
; CHECK-NEXT: [[EXPECTED_TRUE:%.*]] = icmp sle i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[EXPENSIVE:%.*]] = icmp eq i32 [[Y:%.*]], 0
|
||||
; CHECK-NEXT: [[OR_COND:%.*]] = select i1 [[EXPECTED_TRUE]], i1 true, i1 [[EXPENSIVE]]
|
||||
; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof [[PROF23:![0-9]+]]
|
||||
; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof [[PROF24:![0-9]+]]
|
||||
; CHECK: false:
|
||||
; CHECK-NEXT: store i8 42, i8* [[P:%.*]], align 1
|
||||
; CHECK-NEXT: br label [[EXIT]]
|
||||
@ -831,7 +862,7 @@ define void @or_icmps_useful_inverted(i32 %x, i32 %y, i8* %p) {
|
||||
; CHECK-NEXT: [[EXPECTED_FALSE:%.*]] = icmp sgt i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[EXPENSIVE:%.*]] = icmp eq i32 [[Y:%.*]], 0
|
||||
; CHECK-NEXT: [[OR_COND:%.*]] = select i1 [[EXPECTED_FALSE]], i1 true, i1 [[EXPENSIVE]]
|
||||
; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof [[PROF23]]
|
||||
; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof [[PROF24]]
|
||||
; CHECK: false:
|
||||
; CHECK-NEXT: store i8 42, i8* [[P:%.*]], align 1
|
||||
; CHECK-NEXT: br label [[EXIT]]
|
||||
@ -960,7 +991,7 @@ define void @and_icmps_not_that_harmful(i32 %x, i32 %y, i8* %p) {
|
||||
; CHECK-NEXT: [[EXPECTED_FALSE:%.*]] = icmp sgt i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[EXPENSIVE:%.*]] = icmp eq i32 [[Y:%.*]], 0
|
||||
; CHECK-NEXT: [[OR_COND:%.*]] = select i1 [[EXPECTED_FALSE]], i1 [[EXPENSIVE]], i1 false
|
||||
; CHECK-NEXT: br i1 [[OR_COND]], label [[FALSE:%.*]], label [[EXIT:%.*]], !prof [[PROF24:![0-9]+]]
|
||||
; CHECK-NEXT: br i1 [[OR_COND]], label [[FALSE:%.*]], label [[EXIT:%.*]], !prof [[PROF25:![0-9]+]]
|
||||
; CHECK: false:
|
||||
; CHECK-NEXT: store i8 42, i8* [[P:%.*]], align 1
|
||||
; CHECK-NEXT: br label [[EXIT]]
|
||||
@ -992,7 +1023,7 @@ define void @and_icmps_not_that_harmful_inverted(i32 %x, i32 %y, i8* %p) {
|
||||
; CHECK-NEXT: [[EXPECTED_TRUE:%.*]] = icmp sle i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[EXPENSIVE:%.*]] = icmp eq i32 [[Y:%.*]], 0
|
||||
; CHECK-NEXT: [[OR_COND:%.*]] = select i1 [[EXPECTED_TRUE]], i1 [[EXPENSIVE]], i1 false
|
||||
; CHECK-NEXT: br i1 [[OR_COND]], label [[FALSE:%.*]], label [[EXIT:%.*]], !prof [[PROF24]]
|
||||
; CHECK-NEXT: br i1 [[OR_COND]], label [[FALSE:%.*]], label [[EXIT:%.*]], !prof [[PROF25]]
|
||||
; CHECK: false:
|
||||
; CHECK-NEXT: store i8 42, i8* [[P:%.*]], align 1
|
||||
; CHECK-NEXT: br label [[EXIT]]
|
||||
@ -1023,7 +1054,7 @@ define void @and_icmps_useful(i32 %x, i32 %y, i8* %p) {
|
||||
; CHECK-NEXT: [[EXPECTED_TRUE:%.*]] = icmp sgt i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[EXPENSIVE:%.*]] = icmp eq i32 [[Y:%.*]], 0
|
||||
; CHECK-NEXT: [[OR_COND:%.*]] = select i1 [[EXPECTED_TRUE]], i1 [[EXPENSIVE]], i1 false
|
||||
; CHECK-NEXT: br i1 [[OR_COND]], label [[FALSE:%.*]], label [[EXIT:%.*]], !prof [[PROF25:![0-9]+]]
|
||||
; CHECK-NEXT: br i1 [[OR_COND]], label [[FALSE:%.*]], label [[EXIT:%.*]], !prof [[PROF26:![0-9]+]]
|
||||
; CHECK: false:
|
||||
; CHECK-NEXT: store i8 42, i8* [[P:%.*]], align 1
|
||||
; CHECK-NEXT: br label [[EXIT]]
|
||||
@ -1054,7 +1085,7 @@ define void @and_icmps_useful_inverted(i32 %x, i32 %y, i8* %p) {
|
||||
; CHECK-NEXT: [[EXPECTED_FALSE:%.*]] = icmp sle i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[EXPENSIVE:%.*]] = icmp eq i32 [[Y:%.*]], 0
|
||||
; CHECK-NEXT: [[OR_COND:%.*]] = select i1 [[EXPECTED_FALSE]], i1 [[EXPENSIVE]], i1 false
|
||||
; CHECK-NEXT: br i1 [[OR_COND]], label [[FALSE:%.*]], label [[EXIT:%.*]], !prof [[PROF25]]
|
||||
; CHECK-NEXT: br i1 [[OR_COND]], label [[FALSE:%.*]], label [[EXIT:%.*]], !prof [[PROF26]]
|
||||
; CHECK: false:
|
||||
; CHECK-NEXT: store i8 42, i8* [[P:%.*]], align 1
|
||||
; CHECK-NEXT: br label [[EXIT]]
|
||||
@ -1098,6 +1129,7 @@ exit:
|
||||
!17 = !{!"branch_weights", i32 98, i32 1}
|
||||
!18 = !{!"branch_weights", i32 1, i32 98}
|
||||
!19 = !{!"branch_weights", i32 0, i32 0}
|
||||
!20 = !{}
|
||||
|
||||
;.
|
||||
; CHECK: attributes #[[ATTR0:[0-9]+]] = { nounwind uwtable }
|
||||
@ -1125,9 +1157,10 @@ exit:
|
||||
; CHECK: [[PROF18]] = !{!"branch_weights", i32 8, i32 2}
|
||||
; CHECK: [[PROF19]] = !{!"branch_weights", i32 99, i32 1}
|
||||
; CHECK: [[PROF20]] = !{!"branch_weights", i32 1, i32 99}
|
||||
; CHECK: [[PROF21]] = !{!"branch_weights", i32 197, i32 1}
|
||||
; CHECK: [[PROF22]] = !{!"branch_weights", i32 100, i32 98}
|
||||
; CHECK: [[PROF23]] = !{!"branch_weights", i32 101, i32 99}
|
||||
; CHECK: [[PROF24]] = !{!"branch_weights", i32 1, i32 197}
|
||||
; CHECK: [[PROF25]] = !{!"branch_weights", i32 99, i32 101}
|
||||
; CHECK: [[META21:![0-9]+]] = !{}
|
||||
; CHECK: [[PROF22]] = !{!"branch_weights", i32 197, i32 1}
|
||||
; CHECK: [[PROF23]] = !{!"branch_weights", i32 100, i32 98}
|
||||
; CHECK: [[PROF24]] = !{!"branch_weights", i32 101, i32 99}
|
||||
; CHECK: [[PROF25]] = !{!"branch_weights", i32 1, i32 197}
|
||||
; CHECK: [[PROF26]] = !{!"branch_weights", i32 99, i32 101}
|
||||
;.
|
||||
|
@ -110,8 +110,8 @@ end:
|
||||
ret i32 %res
|
||||
}
|
||||
|
||||
define i32 @unpredictable(i1 %c, i32 %a, i32 %b) {
|
||||
; CHECK-LABEL: @unpredictable(
|
||||
define i32 @almost_predictably_nontaken(i1 %c, i32 %a, i32 %b) {
|
||||
; CHECK-LABEL: @almost_predictably_nontaken(
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: call void @sideeffect0()
|
||||
; CHECK-NEXT: br i1 [[C:%.*]], label [[DISPATCH:%.*]], label [[END:%.*]]
|
||||
@ -119,7 +119,7 @@ define i32 @unpredictable(i1 %c, i32 %a, i32 %b) {
|
||||
; CHECK-NEXT: call void @sideeffect1()
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[A:%.*]], [[B:%.*]]
|
||||
; CHECK-NEXT: [[VAL:%.*]] = add i32 [[A]], [[B]]
|
||||
; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[CMP]], i32 [[VAL]], i32 0, !unpredictable !1
|
||||
; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[CMP]], i32 0, i32 [[VAL]], !prof [[PROF1:![0-9]+]]
|
||||
; CHECK-NEXT: br label [[END]]
|
||||
; CHECK: end:
|
||||
; CHECK-NEXT: [[RES:%.*]] = phi i32 [ -1, [[ENTRY:%.*]] ], [ [[SPEC_SELECT]], [[DISPATCH]] ]
|
||||
@ -133,7 +133,42 @@ entry:
|
||||
dispatch:
|
||||
call void @sideeffect1()
|
||||
%cmp = icmp eq i32 %a, %b
|
||||
br i1 %cmp, label %cond.true, label %end, !unpredictable !1 ; unpredictable
|
||||
br i1 %cmp, label %end, label %cond.true, !prof !1 ; almost likely branches to %end
|
||||
|
||||
cond.true:
|
||||
%val = add i32 %a, %b
|
||||
br label %end
|
||||
|
||||
end:
|
||||
%res = phi i32 [ -1, %entry ], [ 0, %dispatch ], [ %val, %cond.true ]
|
||||
call void @sideeffect2()
|
||||
ret i32 %res
|
||||
}
|
||||
|
||||
define i32 @unpredictable(i1 %c, i32 %a, i32 %b) {
|
||||
; CHECK-LABEL: @unpredictable(
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: call void @sideeffect0()
|
||||
; CHECK-NEXT: br i1 [[C:%.*]], label [[DISPATCH:%.*]], label [[END:%.*]]
|
||||
; CHECK: dispatch:
|
||||
; CHECK-NEXT: call void @sideeffect1()
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[A:%.*]], [[B:%.*]]
|
||||
; CHECK-NEXT: [[VAL:%.*]] = add i32 [[A]], [[B]]
|
||||
; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[CMP]], i32 [[VAL]], i32 0, !unpredictable !2
|
||||
; CHECK-NEXT: br label [[END]]
|
||||
; CHECK: end:
|
||||
; CHECK-NEXT: [[RES:%.*]] = phi i32 [ -1, [[ENTRY:%.*]] ], [ [[SPEC_SELECT]], [[DISPATCH]] ]
|
||||
; CHECK-NEXT: call void @sideeffect2()
|
||||
; CHECK-NEXT: ret i32 [[RES]]
|
||||
;
|
||||
entry:
|
||||
call void @sideeffect0()
|
||||
br i1 %c, label %dispatch, label %end
|
||||
|
||||
dispatch:
|
||||
call void @sideeffect1()
|
||||
%cmp = icmp eq i32 %a, %b
|
||||
br i1 %cmp, label %cond.true, label %end, !unpredictable !2 ; unpredictable
|
||||
|
||||
cond.true:
|
||||
%val = add i32 %a, %b
|
||||
@ -154,7 +189,7 @@ define i32 @unpredictable_yet_taken(i1 %c, i32 %a, i32 %b) {
|
||||
; CHECK-NEXT: call void @sideeffect1()
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[A:%.*]], [[B:%.*]]
|
||||
; CHECK-NEXT: [[VAL:%.*]] = add i32 [[A]], [[B]]
|
||||
; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[CMP]], i32 [[VAL]], i32 0, !prof [[PROF0]], !unpredictable !1
|
||||
; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[CMP]], i32 [[VAL]], i32 0, !prof [[PROF0]], !unpredictable !2
|
||||
; CHECK-NEXT: br label [[END]]
|
||||
; CHECK: end:
|
||||
; CHECK-NEXT: [[RES:%.*]] = phi i32 [ -1, [[ENTRY:%.*]] ], [ [[SPEC_SELECT]], [[DISPATCH]] ]
|
||||
@ -168,7 +203,7 @@ entry:
|
||||
dispatch:
|
||||
call void @sideeffect1()
|
||||
%cmp = icmp eq i32 %a, %b
|
||||
br i1 %cmp, label %cond.true, label %end, !prof !0, !unpredictable !1 ; likely branches to %cond.true, yet unpredictable
|
||||
br i1 %cmp, label %cond.true, label %end, !prof !0, !unpredictable !2 ; likely branches to %cond.true, yet unpredictable
|
||||
|
||||
cond.true:
|
||||
%val = add i32 %a, %b
|
||||
@ -189,7 +224,7 @@ define i32 @unpredictable_yet_nontaken(i1 %c, i32 %a, i32 %b) {
|
||||
; CHECK-NEXT: call void @sideeffect1()
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[A:%.*]], [[B:%.*]]
|
||||
; CHECK-NEXT: [[VAL:%.*]] = add i32 [[A]], [[B]]
|
||||
; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[CMP]], i32 0, i32 [[VAL]], !prof [[PROF0]], !unpredictable !1
|
||||
; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[CMP]], i32 0, i32 [[VAL]], !prof [[PROF0]], !unpredictable !2
|
||||
; CHECK-NEXT: br label [[END]]
|
||||
; CHECK: end:
|
||||
; CHECK-NEXT: [[RES:%.*]] = phi i32 [ -1, [[ENTRY:%.*]] ], [ [[SPEC_SELECT]], [[DISPATCH]] ]
|
||||
@ -203,7 +238,7 @@ entry:
|
||||
dispatch:
|
||||
call void @sideeffect1()
|
||||
%cmp = icmp eq i32 %a, %b
|
||||
br i1 %cmp, label %end, label %cond.true, !prof !0, !unpredictable !1 ; likely branches to %end, yet unpredictable
|
||||
br i1 %cmp, label %end, label %cond.true, !prof !0, !unpredictable !2 ; likely branches to %end, yet unpredictable
|
||||
|
||||
cond.true:
|
||||
%val = add i32 %a, %b
|
||||
@ -216,7 +251,9 @@ end:
|
||||
}
|
||||
|
||||
!0 = !{!"branch_weights", i32 99, i32 1}
|
||||
!1 = !{}
|
||||
!1 = !{!"branch_weights", i32 70, i32 1}
|
||||
!2 = !{}
|
||||
|
||||
; CHECK: !0 = !{!"branch_weights", i32 99, i32 1}
|
||||
; CHECK: !1 = !{}
|
||||
; CHECK: !1 = !{!"branch_weights", i32 70, i32 1}
|
||||
; CHECK: !2 = !{}
|
||||
|
Loading…
x
Reference in New Issue
Block a user