blob: 0cd616b31a3b4299e2956ad2a787b3bfb7432d88 [file] [log] [blame]
Jyotsna Verma7dcbb962013-05-14 15:50:49 +00001; RUN: llc -march=hexagon -mcpu=hexagonv4 < %s | FileCheck %s
2
3; Check if the branch probabilities are reflected in the instructions:
4; The basic block placement pass should place the more probable successor
5; block as the fall-through block. The unconditional jump in the predecessor
6; should then get the right hint (not_taken or ":nt")
7
8
9@j = external global i32
10
11define i32 @foo(i32 %a) nounwind {
12; CHECK: if{{ *}}(!p{{[0-3]}}.new) jump:nt
13entry:
14 %tobool = icmp eq i32 %a, 0
15 br i1 %tobool, label %if.else, label %if.then, !prof !0
16
17if.then: ; preds = %entry
18 %add = add nsw i32 %a, 10
19 %call = tail call i32 bitcast (i32 (...)* @foobar to i32 (i32)*)(i32 %add) nounwind
20 br label %return
21
22if.else: ; preds = %entry
23 %call2 = tail call i32 bitcast (i32 (...)* @foobar to i32 (i32)*)(i32 4) nounwind
24 br label %return
25
26return: ; preds = %if.else, %if.then
27 %retval.0 = phi i32 [ %call, %if.then ], [ %call2, %if.else ]
28 ret i32 %retval.0
29}
30
31declare i32 @foobar(...)
32
33define i32 @bar(i32 %a) nounwind {
34; CHECK: if{{ *}}(p{{[0-3]}}.new) jump:nt
35entry:
36 %tobool = icmp eq i32 %a, 0
37 br i1 %tobool, label %if.else, label %if.then, !prof !1
38
39if.then: ; preds = %entry
40 %add = add nsw i32 %a, 10
41 %call = tail call i32 bitcast (i32 (...)* @foobar to i32 (i32)*)(i32 %add) nounwind
42 br label %return
43
44if.else: ; preds = %entry
45 %call2 = tail call i32 bitcast (i32 (...)* @foobar to i32 (i32)*)(i32 4) nounwind
46 br label %return
47
48return: ; preds = %if.else, %if.then
49 %retval.0 = phi i32 [ %call, %if.then ], [ %call2, %if.else ]
50 ret i32 %retval.0
51}
52
53define i32 @foo_bar(i32 %a, i16 signext %b) nounwind {
54; CHECK: if{{ *}}(!cmp.eq(r{{[0-9]*}}.new, #0)) jump:nt
55entry:
David Blaikiea79ac142015-02-27 21:17:42 +000056 %0 = load i32, i32* @j, align 4
Jyotsna Verma7dcbb962013-05-14 15:50:49 +000057 %tobool = icmp eq i32 %0, 0
58 br i1 %tobool, label %if.else, label %if.then, !prof !0
59
60if.then: ; preds = %entry
61 %add = add nsw i32 %a, 10
62 %call = tail call i32 bitcast (i32 (...)* @foobar to i32 (i32)*)(i32 %add) nounwind
63 br label %return
64
65if.else: ; preds = %entry
66 %add1 = add nsw i32 %a, 4
67 %call2 = tail call i32 bitcast (i32 (...)* @foobar to i32 (i32)*)(i32 %add1) nounwind
68 br label %return
69
70return: ; preds = %if.else, %if.then
71 %retval.0 = phi i32 [ %call, %if.then ], [ %call2, %if.else ]
72 ret i32 %retval.0
73}
74
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000075!0 = !{!"branch_weights", i32 64, i32 4}
76!1 = !{!"branch_weights", i32 4, i32 64}