Jyotsna Verma | 7dcbb96 | 2013-05-14 15:50:49 +0000 | [diff] [blame] | 1 | ; 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 | |
| 11 | define i32 @foo(i32 %a) nounwind { |
| 12 | ; CHECK: if{{ *}}(!p{{[0-3]}}.new) jump:nt |
| 13 | entry: |
| 14 | %tobool = icmp eq i32 %a, 0 |
| 15 | br i1 %tobool, label %if.else, label %if.then, !prof !0 |
| 16 | |
| 17 | if.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 | |
| 22 | if.else: ; preds = %entry |
| 23 | %call2 = tail call i32 bitcast (i32 (...)* @foobar to i32 (i32)*)(i32 4) nounwind |
| 24 | br label %return |
| 25 | |
| 26 | return: ; preds = %if.else, %if.then |
| 27 | %retval.0 = phi i32 [ %call, %if.then ], [ %call2, %if.else ] |
| 28 | ret i32 %retval.0 |
| 29 | } |
| 30 | |
| 31 | declare i32 @foobar(...) |
| 32 | |
| 33 | define i32 @bar(i32 %a) nounwind { |
| 34 | ; CHECK: if{{ *}}(p{{[0-3]}}.new) jump:nt |
| 35 | entry: |
| 36 | %tobool = icmp eq i32 %a, 0 |
| 37 | br i1 %tobool, label %if.else, label %if.then, !prof !1 |
| 38 | |
| 39 | if.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 | |
| 44 | if.else: ; preds = %entry |
| 45 | %call2 = tail call i32 bitcast (i32 (...)* @foobar to i32 (i32)*)(i32 4) nounwind |
| 46 | br label %return |
| 47 | |
| 48 | return: ; preds = %if.else, %if.then |
| 49 | %retval.0 = phi i32 [ %call, %if.then ], [ %call2, %if.else ] |
| 50 | ret i32 %retval.0 |
| 51 | } |
| 52 | |
| 53 | define i32 @foo_bar(i32 %a, i16 signext %b) nounwind { |
| 54 | ; CHECK: if{{ *}}(!cmp.eq(r{{[0-9]*}}.new, #0)) jump:nt |
| 55 | entry: |
Manman Ren | 1047fe4 | 2013-09-30 18:17:35 +0000 | [diff] [blame] | 56 | %0 = load i32* @j, align 4 |
Jyotsna Verma | 7dcbb96 | 2013-05-14 15:50:49 +0000 | [diff] [blame] | 57 | %tobool = icmp eq i32 %0, 0 |
| 58 | br i1 %tobool, label %if.else, label %if.then, !prof !0 |
| 59 | |
| 60 | if.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 | |
| 65 | if.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 | |
| 70 | return: ; 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 Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame^] | 75 | !0 = !{!"branch_weights", i32 64, i32 4} |
| 76 | !1 = !{!"branch_weights", i32 4, i32 64} |