aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/Transforms/InstCombine/preserve-profile.ll
blob: dd83805ed3397444dc666c7cbad9215d3c598f86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals all --version 6
; RUN: opt < %s -passes=instcombine -S | FileCheck %s

define i32 @LHSBin(i1 %C) !prof !0 {
; CHECK-LABEL: define i32 @LHSBin(
; CHECK-SAME: i1 [[C:%.*]]) !prof [[PROF0:![0-9]+]] {
; CHECK-NEXT:    [[V:%.*]] = select i1 [[C]], i32 1010, i32 20, !prof [[PROF1:![0-9]+]]
; CHECK-NEXT:    ret i32 [[V]]
;
  %A = select i1 %C, i32 1000, i32 10, !prof !1
  %V = add i32 %A, 10
  ret i32 %V
}

define i32 @RHSBin(i1 %C) !prof !0 {
; CHECK-LABEL: define i32 @RHSBin(
; CHECK-SAME: i1 [[C:%.*]]) !prof [[PROF0]] {
; CHECK-NEXT:    [[V:%.*]] = select i1 [[C]], i32 1010, i32 20, !prof [[PROF1]]
; CHECK-NEXT:    ret i32 [[V]]
;
  %A = select i1 %C, i32 1000, i32 10, !prof !1
  %V = add i32 10, %A
  ret i32 %V;
}

define i32 @BothBin(i1 %C) !prof !0 {
; CHECK-LABEL: define i32 @BothBin(
; CHECK-SAME: i1 [[C:%.*]]) !prof [[PROF0]] {
; CHECK-NEXT:    [[V:%.*]] = select i1 [[C]], i32 2000, i32 20, !prof [[PROF1]]
; CHECK-NEXT:    ret i32 [[V]]
;
  %A = select i1 %C, i32 1000, i32 10, !prof !1
  %B = select i1 %C, i32 1000, i32 10, !prof !1
  %V = add i32 %A, %B
  ret i32 %V;
}

define i32 @NegBin(i1 %C) !prof !0 {
; CHECK-LABEL: define i32 @NegBin(
; CHECK-SAME: i1 [[C:%.*]]) !prof [[PROF0]] {
; CHECK-NEXT:    [[V:%.*]] = select i1 [[C]], i32 1010, i32 0, !prof [[PROF1]]
; CHECK-NEXT:    ret i32 [[V]]
;
  %A = select i1 %C, i32 1000, i32 -10, !prof !1
  %V = add i32 %A, 10
  ret i32 %V
}

!0 = !{!"function_entry_count", i64 1000}
!1 = !{!"branch_weights", i32 2, i32 3}
;.
; CHECK: [[PROF0]] = !{!"function_entry_count", i64 1000}
; CHECK: [[PROF1]] = !{!"branch_weights", i32 2, i32 3}
;.