blob: 66fe7413dd07023f9f50d3859ae7ec001e727f45 [file] [log] [blame]
Sanjay Patelee52b6e2016-03-14 20:18:59 +00001; RUN: opt < %s -S -inline | FileCheck %s
2
Sanjay Patelfd24fb12016-03-16 18:15:34 +00003; Make sure that profile and unpredictable metadata is preserved when cloning a select.
Sanjay Patelee52b6e2016-03-14 20:18:59 +00004
5define i32 @callee_with_select(i1 %c, i32 %a, i32 %b) {
Sanjay Patelfd24fb12016-03-16 18:15:34 +00006 %sel = select i1 %c, i32 %a, i32 %b, !prof !0, !unpredictable !1
Sanjay Patelee52b6e2016-03-14 20:18:59 +00007 ret i32 %sel
8}
9
10define i32 @caller_of_select(i1 %C, i32 %A, i32 %B) {
11 %ret = call i32 @callee_with_select(i1 %C, i32 %A, i32 %B)
12 ret i32 %ret
13
14; CHECK-LABEL: @caller_of_select(
Sanjay Patelfd24fb12016-03-16 18:15:34 +000015; CHECK-NEXT: [[SEL:%.*]] = select i1 %C, i32 %A, i32 %B, !prof !0, !unpredictable !1
Sanjay Patelee52b6e2016-03-14 20:18:59 +000016; CHECK-NEXT: ret i32 [[SEL]]
17}
18
Sanjay Patelfd24fb12016-03-16 18:15:34 +000019; Make sure that profile and unpredictable metadata is preserved when cloning a branch.
Sanjay Patelee52b6e2016-03-14 20:18:59 +000020
21define i32 @callee_with_branch(i1 %c) {
Sanjay Patelfd24fb12016-03-16 18:15:34 +000022 br i1 %c, label %if, label %else, !unpredictable !1, !prof !2
Sanjay Patelee52b6e2016-03-14 20:18:59 +000023if:
24 ret i32 1
25else:
26 ret i32 2
27}
28
29define i32 @caller_of_branch(i1 %C) {
30 %ret = call i32 @callee_with_branch(i1 %C)
31 ret i32 %ret
32
33; CHECK-LABEL: @caller_of_branch(
Sanjay Patelfd24fb12016-03-16 18:15:34 +000034; CHECK-NEXT: br i1 %C, label %{{.*}}, label %{{.*}}, !prof !2, !unpredictable !1
Sanjay Patelee52b6e2016-03-14 20:18:59 +000035}
36
37!0 = !{!"branch_weights", i32 1, i32 2}
Sanjay Patelfd24fb12016-03-16 18:15:34 +000038!1 = !{}
39!2 = !{!"branch_weights", i32 3, i32 4}
40
Sanjay Patelee52b6e2016-03-14 20:18:59 +000041; CHECK: !0 = !{!"branch_weights", i32 1, i32 2}
Sanjay Patelfd24fb12016-03-16 18:15:34 +000042; CHECK: !1 = !{}
43; CHECK: !2 = !{!"branch_weights", i32 3, i32 4}
Sanjay Patelee52b6e2016-03-14 20:18:59 +000044