| 1 |
; RUN: llc -O2 < %s | FileCheck %s |
| 2 |
|
| 3 |
target triple = "powerpc64le-grtev4-linux-gnu" |
| 4 |
|
| 5 |
; No duplication of loop header into entry block. |
| 6 |
define void @no_duplicate1(i64 %a) { |
| 7 |
; CHECK-LABEL: no_duplicate1 |
| 8 |
; CHECK: mr 30, 3 |
| 9 |
; CHECK-NEXT: std 0, 64(1) |
| 10 |
; CHECK-NEXT: b .LBB0_2 |
| 11 |
|
| 12 |
; CHECK: .LBB0_2: |
| 13 |
; CHECK-NEXT: # =>This Inner Loop Header: Depth=1 |
| 14 |
; CHECK-NEXT: cmpldi 30, 100 |
| 15 |
; CHECK-NEXT: bne 0, .LBB0_1 |
| 16 |
entry: |
| 17 |
br label %header |
| 18 |
|
| 19 |
header: |
| 20 |
%ind = phi i64 [%a, %entry], [%val3, %latch] |
| 21 |
%cond1 = icmp eq i64 %ind, 100 |
| 22 |
br i1 %cond1, label %middle, label %latch |
| 23 |
|
| 24 |
middle: |
| 25 |
%condx = call i1 @foo() |
| 26 |
%val1 = xor i64 %ind, 2 |
| 27 |
br label %latch |
| 28 |
|
| 29 |
latch: |
| 30 |
%val2 = phi i64 [%ind, %header], [%val1, %middle] |
| 31 |
%val3 = add i64 %val2, 1 |
| 32 |
%cond2 = call i1 @foo() |
| 33 |
br i1 %cond2, label %end, label %header |
| 34 |
|
| 35 |
end: |
| 36 |
ret void |
| 37 |
} |
| 38 |
|
| 39 |
; No duplication of loop header into latches. |
| 40 |
define void @no_duplicate2(i64 %a) { |
| 41 |
; CHECK-LABEL: no_duplicate2 |
| 42 |
; CHECK: mr 30, 3 |
| 43 |
; CHECK-NEXT: std 0, 64(1) |
| 44 |
; CHECK-NEXT: b .LBB1_2 |
| 45 |
|
| 46 |
; CHECK: .LBB1_2: |
| 47 |
; CHECK-NEXT: # =>This Inner Loop Header: Depth=1 |
| 48 |
; CHECK-NEXT: cmpldi 30, 100 |
| 49 |
; CHECK-NEXT: bne 0, .LBB1_1 |
| 50 |
|
| 51 |
; CHECK: %latch2 |
| 52 |
; CHECK: b .LBB1_2 |
| 53 |
|
| 54 |
; CHECK: %latch3 |
| 55 |
; CHECK: b .LBB1_2 |
| 56 |
entry: |
| 57 |
br label %header |
| 58 |
|
| 59 |
header: |
| 60 |
%ind = phi i64 [%a, %entry], [%val1, %latch1], [%val2, %latch2], [%val2, %latch3] |
| 61 |
%cond1 = icmp eq i64 %ind, 100 |
| 62 |
br i1 %cond1, label %middle1, label %latch1 |
| 63 |
|
| 64 |
latch1: |
| 65 |
%cond2 = call i1 @foo() |
| 66 |
%val1 = xor i64 %ind, 2 |
| 67 |
br i1 %cond2, label %end, label %header |
| 68 |
|
| 69 |
middle1: |
| 70 |
%cond3 = call i1 @foo() |
| 71 |
br i1 %cond3, label %latch1, label %middle2 |
| 72 |
|
| 73 |
middle2: |
| 74 |
%cond4 = call i1 @foo() |
| 75 |
%val2 = add i64 %ind, 1 |
| 76 |
br i1 %cond4, label %latch2, label %latch3 |
| 77 |
|
| 78 |
latch2: |
| 79 |
call void @a() |
| 80 |
br label %header |
| 81 |
|
| 82 |
latch3: |
| 83 |
call void @b() |
| 84 |
br label %header |
| 85 |
|
| 86 |
end: |
| 87 |
ret void |
| 88 |
} |
| 89 |
|
| 90 |
|
| 91 |
declare i1 @foo() |
| 92 |
declare void @a() |
| 93 |
declare void @b() |