| 1 |
; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \ |
| 2 |
; RUN: -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | FileCheck %s |
| 3 |
; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr8 \ |
| 4 |
; RUN: -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | FileCheck %s |
| 5 |
; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -ppc-late-peephole=false \ |
| 6 |
; RUN: -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | FileCheck %s \ |
| 7 |
; RUN: --implicit-check-not creqv --implicit-check-not crxor |
| 8 |
|
| 9 |
|
| 10 |
; For known CRBit spills, CRSET/CRUNSET, it is more efficient to just load and |
| 11 |
; spill the known value. These tests verify that for CRSET and CRUNSET spills |
| 12 |
; we do not extract the bit for spilling. |
| 13 |
|
| 14 |
%struct.anon = type { i32 } |
| 15 |
|
| 16 |
@b = common dso_local global ptr null, align 8 |
| 17 |
@a = common dso_local global i64 0, align 8 |
| 18 |
|
| 19 |
; Function Attrs: nounwind |
| 20 |
define dso_local signext i32 @spillCRSET(i32 signext %p1, i32 signext %p2) { |
| 21 |
; CHECK-LABEL: spillCRSET: |
| 22 |
; CHECK: # %bb.2: |
| 23 |
; CHECK-DAG: crnot [[CREG:.*]]*cr5+lt, eq |
| 24 |
; CHECK-DAG: mfocrf [[REG2:.*]], [[CREG]] |
| 25 |
; CHECK-DAG: rlwinm [[REG2]], [[REG2]] |
| 26 |
; CHECK: .LBB0_3: |
| 27 |
; CHECK-NOT: #UNENCODED_NOP |
| 28 |
; CHECK: lis [[REG1:.*]], -32768 |
| 29 |
; CHECK: .LBB0_4: |
| 30 |
; CHECK-NOT: mfocrf [[REG2:.*]], [[CREG]] |
| 31 |
; CHECK-NOT: rlwinm [[REG2]], [[REG2]] |
| 32 |
; CHECK: stw [[REG1]] |
| 33 |
; CHECK: # %bb.5: |
| 34 |
|
| 35 |
entry: |
| 36 |
%tobool = icmp eq i32 %p2, 0 |
| 37 |
%tobool2 = icmp eq i32 %p1, 0 |
| 38 |
br label %redo_first_pass |
| 39 |
|
| 40 |
redo_first_pass: ; preds = %for.end, %entry |
| 41 |
br i1 %tobool, label %if.end, label %if.then |
| 42 |
|
| 43 |
if.then: ; preds = %redo_first_pass |
| 44 |
%call = tail call signext i32 @fn2() #2 |
| 45 |
%tobool1 = icmp ne i32 %call, 0 |
| 46 |
br label %if.end |
| 47 |
|
| 48 |
if.end: ; preds = %redo_first_pass, %if.then |
| 49 |
%c.1.off0 = phi i1 [ %tobool1, %if.then ], [ true, %redo_first_pass ] |
| 50 |
br i1 %tobool2, label %if.end4, label %if.then3 |
| 51 |
|
| 52 |
if.then3: ; preds = %if.end |
| 53 |
%0 = load ptr, ptr @b, align 8 |
| 54 |
store i32 1, ptr %0, align 4 |
| 55 |
br label %if.end4 |
| 56 |
|
| 57 |
if.end4: ; preds = %if.end, %if.then3 |
| 58 |
tail call void asm sideeffect "#DO_NOTHING", "~{cr0},~{cr1},~{cr2},~{cr3},~{cr4},~{cr5},~{cr6},~{cr7}"() |
| 59 |
br i1 %c.1.off0, label %if.then6, label %if.end13 |
| 60 |
|
| 61 |
if.then6: ; preds = %if.end4 |
| 62 |
%1 = load i64, ptr @a, align 8 |
| 63 |
%cmp21 = icmp eq i64 %1, 0 |
| 64 |
br i1 %cmp21, label %if.end13, label %for.body |
| 65 |
|
| 66 |
for.body: ; preds = %if.then6, %for.body |
| 67 |
%s.122 = phi i64 [ %inc, %for.body ], [ 0, %if.then6 ] |
| 68 |
%call7 = tail call signext i32 @fn3() |
| 69 |
%inc = add nuw i64 %s.122, 1 |
| 70 |
%exitcond = icmp eq i64 %inc, %1 |
| 71 |
br i1 %exitcond, label %for.end, label %for.body |
| 72 |
|
| 73 |
for.end: ; preds = %for.body |
| 74 |
br i1 %cmp21, label %if.end13, label %redo_first_pass |
| 75 |
|
| 76 |
if.end13: ; preds = %if.then6, %for.end, %if.end4 |
| 77 |
ret i32 0 |
| 78 |
} |
| 79 |
|
| 80 |
%struct.p5rx = type { i32 } |
| 81 |
|
| 82 |
; Function Attrs: nounwind |
| 83 |
define dso_local signext i32 @spillCRUNSET(ptr readonly %p1, i32 signext %p2, i32 signext %p3) { |
| 84 |
; CHECK-LABEL: spillCRUNSET: |
| 85 |
; CHECK: # %bb.0: # %entry |
| 86 |
; CHECK-DAG: li [[REG1:.*]], 0 |
| 87 |
; CHECK-NOT: #UNENCODED_NOP |
| 88 |
; CHECK-NOT: mfocrf [[REG2:.*]], [[CREG]] |
| 89 |
; CHECK-NOT: rlwinm [[REG2]], [[REG2]] |
| 90 |
; CHECK: stw [[REG1]] |
| 91 |
; CHECK: .LBB1_1: |
| 92 |
entry: |
| 93 |
%and = and i32 %p3, 128 |
| 94 |
%tobool = icmp eq i32 %and, 0 |
| 95 |
%tobool2 = icmp eq ptr %p1, null |
| 96 |
%tobool12 = icmp eq i32 %p2, 0 |
| 97 |
br label %redo_first_pass |
| 98 |
|
| 99 |
redo_first_pass: ; preds = %if.end11, %entry |
| 100 |
%a.0.off0 = phi i1 [ false, %entry ], [ %a.1.off0, %if.end11 ] |
| 101 |
br i1 %tobool, label %if.end, label %if.then |
| 102 |
|
| 103 |
if.then: ; preds = %redo_first_pass |
| 104 |
%call = tail call signext i32 @fn2() |
| 105 |
%tobool1 = icmp ne i32 %call, 0 |
| 106 |
br label %if.end |
| 107 |
|
| 108 |
if.end: ; preds = %redo_first_pass, %if.then |
| 109 |
%a.1.off0 = phi i1 [ %tobool1, %if.then ], [ %a.0.off0, %redo_first_pass ] |
| 110 |
tail call void asm sideeffect "#DO_NOTHING", "~{cr0},~{cr1},~{cr2},~{cr3},~{cr4},~{cr5},~{cr6},~{cr7}"() |
| 111 |
br i1 %tobool2, label %if.end11, label %land.lhs.true |
| 112 |
|
| 113 |
land.lhs.true: ; preds = %if.end |
| 114 |
%call3 = tail call signext i32 @fn3() |
| 115 |
%tobool4 = icmp eq i32 %call3, 0 |
| 116 |
br i1 %tobool4, label %if.end11, label %land.lhs.true5 |
| 117 |
|
| 118 |
land.lhs.true5: ; preds = %land.lhs.true |
| 119 |
%0 = load i32, ptr %p1, align 4 |
| 120 |
%tobool6 = icmp eq i32 %0, 0 |
| 121 |
%a.1.off0.not = xor i1 %a.1.off0, true |
| 122 |
%brmerge = or i1 %tobool6, %a.1.off0.not |
| 123 |
br i1 %brmerge, label %if.end11, label %if.then9 |
| 124 |
|
| 125 |
if.then9: ; preds = %land.lhs.true5 |
| 126 |
%call10 = tail call signext i32 @fn4() |
| 127 |
br label %if.end11 |
| 128 |
|
| 129 |
if.end11: ; preds = %land.lhs.true5, %land.lhs.true, %if.end, %if.then9 |
| 130 |
br i1 %tobool12, label %if.end14, label %redo_first_pass |
| 131 |
|
| 132 |
if.end14: ; preds = %if.end11 |
| 133 |
ret i32 0 |
| 134 |
} |
| 135 |
|
| 136 |
declare signext i32 @fn2(...) |
| 137 |
declare signext i32 @fn3(...) |
| 138 |
declare signext i32 @fn4(...) |