1; RUN: llc %s -x86-early-ifcvt -pass-remarks='early-ifcvt' -pass-remarks-missed='early-ifcvt' -mcpu=k8 -o - 2>&1 | FileCheck %s
2target triple = "x86_64-none-none"
3
4; CHECK: remark: <unknown>:0:0: performing if-conversion on branch:
5; CHECK-SAME: the condition adds {{[0-9]+}} cycle{{s?}} to the critical path,
6; CHECK-SAME: and the short leg adds another {{[0-9]+}} cycles{{s?}},
7; CHECK-SAME: and the long leg adds another {{[0-9]+}} cycles{{s?}},
8; CHECK-SAME: each staying under the threshold of {{[0-9]+}} cycles{{s?}}.
9define i32 @mm1(i1 %pred, i32 %val) {
10entry:
11  br i1 %pred, label %if.true, label %if.else
12
13if.true:
14  %v1 = add i32 1, %val
15  br label %if.else
16
17if.else:
18  %res = phi i32 [ %val, %entry ], [ %v1, %if.true ]
19  ret i32 %res
20}
21
22; CHECK: remark: <unknown>:0:0: did not if-convert branch:
23; CHECK-SAME: the condition would add {{[0-9]+}} cycles{{s?}} to the critical path,
24; CHECK-SAME: and the short leg would add another {{[0-9]+}} cycles{{s?}},
25; CHECK-SAME: and the long leg would add another {{[0-9]+}} cycles{{s?}} exceeding the limit of {{[0-9]+}} cycles{{s?}}.
26define i32 @mm2(i1 %pred, i32 %val, i32 %e1, i32 %e2, i32 %e3, i32 %e4, i32 %e5) {
27entry:
28  br i1 %pred, label %if.true, label %if.else
29
30if.true:
31  %v1 = add i32 %e1, %val
32  %v2 = add i32 %e2, %v1
33  %v3 = add i32 %e3, %v2
34  %v4 = add i32 %e4, %v3
35  br label %if.else
36
37if.else:
38  %res = phi i32 [ %val, %entry ], [ %v4, %if.true ]
39  ret i32 %res
40}
41
42; CHECK: did not if-convert branch:
43; CHECK-SAME: the resulting critical path ({{[0-9]+}} cycles{{s?}})
44; CHECK-SAME: would extend the shorter leg's critical path ({{[0-9]+}} cycle{{s?}})
45; CHECK-SAME: by more than the threshold of {{[0-9]+}} cycles{{s?}},
46; CHECK-SAME: which cannot be hidden by available ILP.
47define i32 @mm3(i1 %pred, i32 %val, i32 %e1, i128 %e2, i128 %e3, i128 %e4, i128 %e5) {
48entry:
49  br i1 %pred, label %if.true, label %if.false
50
51if.true:
52  br label %if.endif
53
54if.false:
55  %f1 = mul i32 %e1, %e1
56  %f3 = sext i32 %f1 to i128
57  %f4 = mul i128 %e2, %f3
58  %f6 = add i128 %e3, %f4
59  %f7 = xor i128 %e4, %f6
60  %f8 = xor i128 %e5, %f7
61  %a1 = ashr i128 %f8, %e5
62  %f5 = trunc i128 %a1 to i32
63  br label %if.endif
64
65if.endif:
66  %r1 = phi i32 [ %val, %if.true ], [ %f1, %if.false ]
67  %r2 = phi i32 [ %val, %if.true ], [ %f5, %if.false ]
68  %res = add i32 %r1, %r2
69  ret i32 %res
70}
71