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
7 ; For known CRBit spills, CRSET/CRUNSET, it is more efficient to just load and
8 ; spill the known value. These tests verify that for CRSET and CRUNSET spills
9 ; we do not extract the bit for spilling.
11 %struct.anon = type { i32 }
13 @b = common dso_local global %struct.anon* null, align 8
14 @a = common dso_local global i64 0, align 8
16 ; Function Attrs: nounwind
17 define dso_local signext i32 @spillCRSET(i32 signext %p1, i32 signext %p2) {
18 ; CHECK-LABEL: spillCRSET:
20 ; CHECK-DAG: crnor [[CREG:.*]]*cr5+lt, eq, eq
21 ; CHECK-DAG: mfocrf [[REG2:.*]], [[CREG]]
22 ; CHECK-DAG: rlwinm [[REG2]], [[REG2]]
24 ; CHECK-DAG: creqv [[CREG:.*]]*cr5+lt, [[CREG]]*cr5+lt, [[CREG]]*cr5+lt
25 ; CHECK: lis [[REG1:.*]], -32768
27 ; CHECK-NOT: mfocrf [[REG2:.*]], [[CREG]]
28 ; CHECK-NOT: rlwinm [[REG2]], [[REG2]]
33 %tobool = icmp eq i32 %p2, 0
34 %tobool2 = icmp eq i32 %p1, 0
35 br label %redo_first_pass
37 redo_first_pass: ; preds = %for.end, %entry
38 br i1 %tobool, label %if.end, label %if.then
40 if.then: ; preds = %redo_first_pass
41 %call = tail call signext i32 bitcast (i32 (...)* @fn2 to i32 ()*)() #2
42 %tobool1 = icmp ne i32 %call, 0
45 if.end: ; preds = %redo_first_pass, %if.then
46 %c.1.off0 = phi i1 [ %tobool1, %if.then ], [ true, %redo_first_pass ]
47 br i1 %tobool2, label %if.end4, label %if.then3
49 if.then3: ; preds = %if.end
50 %0 = load %struct.anon*, %struct.anon** @b, align 8
51 %contains_i = getelementptr inbounds %struct.anon, %struct.anon* %0, i64 0, i32 0
52 store i32 1, i32* %contains_i, align 4
55 if.end4: ; preds = %if.end, %if.then3
56 tail call void asm sideeffect "#DO_NOTHING", "~{cr0},~{cr1},~{cr2},~{cr3},~{cr4},~{cr5},~{cr6},~{cr7}"()
57 br i1 %c.1.off0, label %if.then6, label %if.end13
59 if.then6: ; preds = %if.end4
60 %1 = load i64, i64* @a, align 8
61 %cmp21 = icmp eq i64 %1, 0
62 br i1 %cmp21, label %if.end13, label %for.body
64 for.body: ; preds = %if.then6, %for.body
65 %s.122 = phi i64 [ %inc, %for.body ], [ 0, %if.then6 ]
66 %call7 = tail call signext i32 bitcast (i32 (...)* @fn3 to i32 ()*)()
67 %inc = add nuw i64 %s.122, 1
68 %exitcond = icmp eq i64 %inc, %1
69 br i1 %exitcond, label %for.end, label %for.body
71 for.end: ; preds = %for.body
72 br i1 %cmp21, label %if.end13, label %redo_first_pass
74 if.end13: ; preds = %if.then6, %for.end, %if.end4
78 %struct.p5rx = type { i32 }
80 ; Function Attrs: nounwind
81 define dso_local signext i32 @spillCRUNSET(%struct.p5rx* readonly %p1, i32 signext %p2, i32 signext %p3) {
82 ; CHECK-LABEL: spillCRUNSET:
83 ; CHECK: # %bb.0: # %entry
84 ; CHECK-DAG: crxor [[CREG:.*]]*cr5+lt, [[CREG]]*cr5+lt, [[CREG]]*cr5+lt
85 ; CHECK-DAG: li [[REG1:.*]], 0
86 ; CHECK-NOT: mfocrf [[REG2:.*]], [[CREG]]
87 ; CHECK-NOT: rlwinm [[REG2]], [[REG2]]
91 %and = and i32 %p3, 128
92 %tobool = icmp eq i32 %and, 0
93 %tobool2 = icmp eq %struct.p5rx* %p1, null
94 %sv_any = getelementptr inbounds %struct.p5rx, %struct.p5rx* %p1, i64 0, i32 0
95 %tobool12 = icmp eq i32 %p2, 0
96 br label %redo_first_pass
98 redo_first_pass: ; preds = %if.end11, %entry
99 %a.0.off0 = phi i1 [ false, %entry ], [ %a.1.off0, %if.end11 ]
100 br i1 %tobool, label %if.end, label %if.then
102 if.then: ; preds = %redo_first_pass
103 %call = tail call signext i32 bitcast (i32 (...)* @fn2 to i32 ()*)()
104 %tobool1 = icmp ne i32 %call, 0
107 if.end: ; preds = %redo_first_pass, %if.then
108 %a.1.off0 = phi i1 [ %tobool1, %if.then ], [ %a.0.off0, %redo_first_pass ]
109 tail call void asm sideeffect "#DO_NOTHING", "~{cr0},~{cr1},~{cr2},~{cr3},~{cr4},~{cr5},~{cr6},~{cr7}"()
110 br i1 %tobool2, label %if.end11, label %land.lhs.true
112 land.lhs.true: ; preds = %if.end
113 %call3 = tail call signext i32 bitcast (i32 (...)* @fn3 to i32 ()*)()
114 %tobool4 = icmp eq i32 %call3, 0
115 br i1 %tobool4, label %if.end11, label %land.lhs.true5
117 land.lhs.true5: ; preds = %land.lhs.true
118 %0 = load i32, i32* %sv_any, align 4
119 %tobool6 = icmp eq i32 %0, 0
120 %a.1.off0.not = xor i1 %a.1.off0, true
121 %brmerge = or i1 %tobool6, %a.1.off0.not
122 br i1 %brmerge, label %if.end11, label %if.then9
124 if.then9: ; preds = %land.lhs.true5
125 %call10 = tail call signext i32 bitcast (i32 (...)* @fn4 to i32 ()*)()
128 if.end11: ; preds = %land.lhs.true5, %land.lhs.true, %if.end, %if.then9
129 br i1 %tobool12, label %if.end14, label %redo_first_pass
131 if.end14: ; preds = %if.end11
135 declare signext i32 @fn2(...)
136 declare signext i32 @fn3(...)
137 declare signext i32 @fn4(...)