Krzysztof Parzyszek | fb33824 | 2015-10-06 15:49:14 +0000 | [diff] [blame] | 1 | ; RUN: llc -march=hexagon -mcpu=hexagonv5 -hexagon-eif=0 -print-machineinstrs=if-converter %s -o /dev/null 2>&1 | FileCheck %s |
Cong Hou | d40105d | 2015-09-18 20:22:41 +0000 | [diff] [blame] | 2 | ; Check that the edge weights are updated correctly after if-conversion. |
| 3 | |
Francis Visoiu Mistrih | da89d18 | 2018-02-08 05:02:00 +0000 | [diff] [blame] | 4 | ; CHECK: bb.3.if{{[0-9a-zA-Z.]*}}: |
Francis Visoiu Mistrih | 39ec2e9 | 2018-02-09 00:10:31 +0000 | [diff] [blame] | 5 | ; CHECK: successors: %bb.2(0x0ccccccd), %bb.1(0x73333333) |
Cong Hou | d40105d | 2015-09-18 20:22:41 +0000 | [diff] [blame] | 6 | @a = external global i32 |
| 7 | @d = external global i32 |
| 8 | |
| 9 | ; In the following CFG, A,B,C,D will be if-converted into a single block. |
| 10 | ; Check if the edge weights on edges to E and F are maintained correctly. |
| 11 | ; |
| 12 | ; A |
| 13 | ; / \ |
| 14 | ; B C |
| 15 | ; \ / |
| 16 | ; D |
| 17 | ; / \ |
| 18 | ; E F |
| 19 | ; |
| 20 | define void @test1(i8 zeroext %la, i8 zeroext %lb) { |
| 21 | entry: |
| 22 | %cmp0 = call i1 @pred() |
| 23 | br i1 %cmp0, label %if.else2, label %if.then0, !prof !1 |
| 24 | |
| 25 | if.else2: |
| 26 | call void @bar(i32 2) |
| 27 | br label %if.end2 |
| 28 | |
| 29 | if.end2: |
| 30 | call void @foo(i32 2) |
| 31 | br label %return |
| 32 | |
| 33 | if.end: |
| 34 | %storemerge = phi i32 [ %and, %if.else ], [ %shl, %if.then ] |
| 35 | store i32 %storemerge, i32* @a, align 4 |
| 36 | %0 = load i32, i32* @d, align 4 |
| 37 | %cmp2 = call i1 @pred() |
| 38 | br i1 %cmp2, label %if.end2, label %if.else2, !prof !2 |
| 39 | |
| 40 | if.then0: |
| 41 | %cmp = icmp eq i8 %la, %lb |
| 42 | br i1 %cmp, label %if.then, label %if.else, !prof !1 |
| 43 | |
| 44 | if.then: |
| 45 | %conv1 = zext i8 %la to i32 |
| 46 | %shl = shl nuw nsw i32 %conv1, 16 |
| 47 | br label %if.end |
| 48 | |
| 49 | if.else: |
| 50 | %and8 = and i8 %lb, %la |
| 51 | %and = zext i8 %and8 to i32 |
| 52 | br label %if.end |
| 53 | |
| 54 | return: |
| 55 | call void @foo(i32 2) |
| 56 | ret void |
| 57 | } |
| 58 | |
| 59 | declare void @foo(i32) |
| 60 | declare void @bar(i32) |
| 61 | declare i1 @pred() |
| 62 | |
| 63 | !1 = !{!"branch_weights", i32 80, i32 20} |
| 64 | !2 = !{!"branch_weights", i32 10, i32 90} |