llvm.org GIT mirror llvm / 4a0e897
[PowerPC] Turn on CR-Logical reducer pass This re-commits r375152 which was pulled in r375233 because it broke the EXPENSIVE_CHECKS bot on Windows. The reason for the failure was a bug in the pass that the commit turned on by default. This patch fixes that bug and turns the pass back on. This patch has been verified on the buildbot that originally failed thanks to Simon Pilgrim. Differential revision: https://reviews.llvm.org/D52431 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@375497 91177308-0d34-0410-b5e6-96231b3b80d8 Nemanja Ivanovic 1 year, 6 days ago
7 changed file(s) with 58 addition(s) and 50 deletion(s). Raw diff Collapse all Expand all
380380 const MachineBranchProbabilityInfo *MBPI;
381381
382382 // A vector to contain all the CR logical operations
383 std::vector> AllCRLogicalOps;
383 SmallVector> AllCRLogicalOps;
384384 void initialize(MachineFunction &MFParm);
385385 void collectCRLogicals();
386 bool handleCROp(CRLogicalOpInfo &CRI);
386 bool handleCROp(unsigned Idx);
387387 bool splitBlockOnBinaryCROp(CRLogicalOpInfo &CRI);
388388 static bool isCRLogical(MachineInstr &MI) {
389389 unsigned Opc = MI.getOpcode();
397397 // Not using a range-based for loop here as the vector may grow while being
398398 // operated on.
399399 for (unsigned i = 0; i < AllCRLogicalOps.size(); i++)
400 Changed |= handleCROp(AllCRLogicalOps[i]);
400 Changed |= handleCROp(i);
401401 return Changed;
402402 }
403403
577577 /// a unary CR logical might be used to change the condition code on a
578578 /// comparison feeding it. A nullary CR logical might simply be removable
579579 /// if the user of the bit it [un]sets can be transformed.
580 bool PPCReduceCRLogicals::handleCROp(CRLogicalOpInfo &CRI) {
580 bool PPCReduceCRLogicals::handleCROp(unsigned Idx) {
581581 // We can definitely split a block on the inputs to a binary CR operation
582582 // whose defs and (single) use are within the same block.
583583 bool Changed = false;
584 CRLogicalOpInfo CRI = AllCRLogicalOps[Idx];
584585 if (CRI.IsBinary && CRI.ContainedInBlock && CRI.SingleUse && CRI.FeedsBR &&
585586 CRI.DefsSingleUse) {
586587 Changed = splitBlockOnBinaryCROp(CRI);
9292 static cl::opt
9393 ReduceCRLogical("ppc-reduce-cr-logicals",
9494 cl::desc("Expand eligible cr-logical binary ops to branches"),
95 cl::init(false), cl::Hidden);
95 cl::init(true), cl::Hidden);
9696 extern "C" void LLVMInitializePowerPCTarget() {
9797 // Register the targets
9898 RegisterTargetMachine A(getThePPC32Target());
3535 ; CHECK-NEXT: # %bb.1: # %bb5
3636 ; CHECK-NEXT: li 3, 0
3737 ; CHECK-NEXT: li 4, 0
38 ; CHECK-NEXT: b .LBB0_16
38 ; CHECK-NEXT: b .LBB0_17
3939 ; CHECK-NEXT: .LBB0_2: # %bb1
4040 ; CHECK-NEXT: lfd 0, 400(1)
4141 ; CHECK-NEXT: lis 3, 15856
165165 ; CHECK-NEXT: bl __gcc_qsub@PLT
166166 ; CHECK-NEXT: stfd 2, 176(1)
167167 ; CHECK-NEXT: stfd 1, 168(1)
168 ; CHECK-NEXT: fcmpu 0, 2, 27
168 ; CHECK-NEXT: fcmpu 1, 2, 27
169169 ; CHECK-NEXT: lwz 3, 180(1)
170 ; CHECK-NEXT: fcmpu 1, 1, 27
171 ; CHECK-NEXT: crandc 20, 6, 0
172 ; CHECK-NEXT: cror 21, 5, 7
170 ; CHECK-NEXT: fcmpu 0, 1, 27
171 ; CHECK-NEXT: crandc 20, 2, 4
173172 ; CHECK-NEXT: stw 3, 268(1)
174 ; CHECK-NEXT: cror 20, 21, 20
175173 ; CHECK-NEXT: lwz 3, 176(1)
176174 ; CHECK-NEXT: stw 3, 264(1)
177175 ; CHECK-NEXT: lwz 3, 172(1)
180178 ; CHECK-NEXT: lwz 3, 168(1)
181179 ; CHECK-NEXT: stw 3, 272(1)
182180 ; CHECK-NEXT: lfd 31, 272(1)
183 ; CHECK-NEXT: bc 12, 20, .LBB0_13
184 ; CHECK-NEXT: # %bb.10: # %bb2
181 ; CHECK-NEXT: bc 12, 20, .LBB0_14
182 ; CHECK-NEXT: # %bb.10: # %bb1
183 ; CHECK-NEXT: cror 20, 1, 3
184 ; CHECK-NEXT: bc 12, 20, .LBB0_14
185 ; CHECK-NEXT: # %bb.11: # %bb2
185186 ; CHECK-NEXT: fneg 28, 31
186187 ; CHECK-NEXT: stfd 28, 48(1)
187188 ; CHECK-NEXT: lis 3, 16864
230231 ; CHECK-NEXT: crandc 20, 6, 1
231232 ; CHECK-NEXT: cror 20, 4, 20
232233 ; CHECK-NEXT: addis 3, 3, -32768
233 ; CHECK-NEXT: bc 12, 20, .LBB0_12
234 ; CHECK-NEXT: # %bb.11: # %bb2
234 ; CHECK-NEXT: bc 12, 20, .LBB0_13
235 ; CHECK-NEXT: # %bb.12: # %bb2
235236 ; CHECK-NEXT: ori 3, 4, 0
236 ; CHECK-NEXT: b .LBB0_12
237 ; CHECK-NEXT: .LBB0_12: # %bb2
237 ; CHECK-NEXT: b .LBB0_13
238 ; CHECK-NEXT: .LBB0_13: # %bb2
238239 ; CHECK-NEXT: subfic 4, 3, 0
239240 ; CHECK-NEXT: subfe 3, 29, 30
240 ; CHECK-NEXT: b .LBB0_16
241 ; CHECK-NEXT: .LBB0_13: # %bb3
241 ; CHECK-NEXT: b .LBB0_17
242 ; CHECK-NEXT: .LBB0_14: # %bb3
242243 ; CHECK-NEXT: stfd 31, 112(1)
243244 ; CHECK-NEXT: li 3, 0
244245 ; CHECK-NEXT: stw 3, 148(1)
285286 ; CHECK-NEXT: crandc 20, 6, 0
286287 ; CHECK-NEXT: cror 20, 5, 20
287288 ; CHECK-NEXT: addis 3, 3, -32768
288 ; CHECK-NEXT: bc 12, 20, .LBB0_14
289 ; CHECK-NEXT: b .LBB0_15
290 ; CHECK-NEXT: .LBB0_14: # %bb3
289 ; CHECK-NEXT: bc 12, 20, .LBB0_15
290 ; CHECK-NEXT: b .LBB0_16
291 ; CHECK-NEXT: .LBB0_15: # %bb3
291292 ; CHECK-NEXT: addi 4, 3, 0
292 ; CHECK-NEXT: .LBB0_15: # %bb3
293 ; CHECK-NEXT: .LBB0_16: # %bb3
293294 ; CHECK-NEXT: mr 3, 30
294 ; CHECK-NEXT: .LBB0_16: # %bb5
295 ; CHECK-NEXT: .LBB0_17: # %bb5
295296 ; CHECK-NEXT: lfd 31, 456(1) # 8-byte Folded Reload
296297 ; CHECK-NEXT: lfd 30, 448(1) # 8-byte Folded Reload
297298 ; CHECK-NEXT: lfd 29, 440(1) # 8-byte Folded Reload
None ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-unknown < %s | FileCheck %s
1 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-unknown < %s | FileCheck %s
0 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-unknown \
1 ; RUN: -ppc-reduce-cr-logicals=false < %s | FileCheck %s
2 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-unknown \
3 ; RUN: -ppc-reduce-cr-logicals=false < %s | FileCheck %s
24
35 define signext i32 @testi32slt(i32 signext %c1, i32 signext %c2, i32 signext %c3, i32 signext %c4, i32 signext %a1, i32 signext %a2) #0 {
46 ; CHECK-LABEL: testi32slt
1313 ; CHECK-NEXT: li 4, 0
1414 ; CHECK-NEXT: .p2align 5
1515 ; CHECK-NEXT: .LBB0_2: #
16 ; CHECK-NEXT: sldi 6, 6, 4
1617 ; CHECK-NEXT: cmplwi 4, 14
17 ; CHECK-NEXT: cmpd 1, 3, 4
18 ; CHECK-NEXT: sldi 6, 6, 4
19 ; CHECK-NEXT: cror 20, 6, 1
20 ; CHECK-NEXT: addi 4, 4, 1
21 ; CHECK-NEXT: bc 4, 20, .LBB0_2
22 ; CHECK-NEXT: # %bb.3:
18 ; CHECK-NEXT: addi 7, 4, 1
19 ; CHECK-NEXT: bc 12, 1, .LBB0_4
20 ; CHECK-NEXT: # %bb.3: #
21 ; CHECK-NEXT: cmpd 3, 4
22 ; CHECK-NEXT: mr 4, 7
23 ; CHECK-NEXT: bc 4, 2, .LBB0_2
24 ; CHECK-NEXT: .LBB0_4:
2325 ; CHECK-NEXT: std 6, 8(5)
2426 ; CHECK-NEXT: blr
2527
1515 ; CHECK-NEXT: std r0, 16(r1)
1616 ; CHECK-NEXT: stdu r1, -64(r1)
1717 ; CHECK-NEXT: mr r29, r5
18 ; CHECK-NEXT: cmpwi cr1, r4, 11
1918 ; CHECK-NEXT: mr r30, r3
2019 ; CHECK-NEXT: extsw r28, r4
2120 ; CHECK-NEXT: std r2, 24(r1)
2221 ; CHECK-NEXT: cmpwi r29, 1
23 ; CHECK-NEXT: cror 4*cr5+lt, lt, 4*cr1+lt
24 ; CHECK-NEXT: bc 12, 4*cr5+lt, .LBB0_2
22 ; CHECK-NEXT: bc 12, lt, .LBB0_3
23 ; CHECK-NEXT: # %bb.1: # %entry
24 ; CHECK-NEXT: cmpwi cr0, r4, 11
25 ; CHECK-NEXT: bc 12, lt, .LBB0_3
2526 ; CHECK-NEXT: .p2align 5
26 ; CHECK-NEXT: .LBB0_1: # %for.body.us
27 ; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
27 ; CHECK-NEXT: .LBB0_2: # %for.body.us
28 ; CHECK-NEXT: #
2829 ; CHECK-NEXT: mtctr r30
2930 ; CHECK-NEXT: mr r3, r28
3031 ; CHECK-NEXT: mr r12, r30
3233 ; CHECK-NEXT: ld 2, 24(r1)
3334 ; CHECK-NEXT: addi r29, r29, -1
3435 ; CHECK-NEXT: cmplwi r29, 0
35 ; CHECK-NEXT: bne cr0, .LBB0_1
36 ; CHECK-NEXT: .LBB0_2: # %for.cond.cleanup
36 ; CHECK-NEXT: bne cr0, .LBB0_2
37 ; CHECK-NEXT: .LBB0_3: # %for.cond.cleanup
3738 ; CHECK-NEXT: mtctr r30
3839 ; CHECK-NEXT: mr r3, r28
3940 ; CHECK-NEXT: mr r12, r30
239239 define i128 @invalidv1i128(<2 x i128> %v1, <2 x i128> %v2) {
240240 ; CHECK-LABEL: invalidv1i128:
241241 ; CHECK: # %bb.0:
242 ; CHECK-NEXT: mfvsrd 3, 36
242243 ; CHECK-NEXT: xxswapd 0, 36
243 ; CHECK-NEXT: mfvsrd 4, 36
244 ; CHECK-NEXT: mfvsrd 5, 34
244 ; CHECK-NEXT: mfvsrd 4, 34
245 ; CHECK-NEXT: xxswapd 1, 34
246 ; CHECK-NEXT: cmpld 4, 3
247 ; CHECK-NEXT: cmpd 1, 4, 3
245248 ; CHECK-NEXT: mfvsrd 3, 0
246 ; CHECK-NEXT: xxswapd 0, 34
247 ; CHECK-NEXT: cmpld 5, 4
248 ; CHECK-NEXT: cmpd 1, 5, 4
249249 ; CHECK-NEXT: crandc 20, 4, 2
250 ; CHECK-NEXT: mfvsrd 6, 0
251 ; CHECK-NEXT: cmpld 1, 6, 3
252 ; CHECK-NEXT: crand 21, 2, 4
253 ; CHECK-NEXT: cror 20, 21, 20
254 ; CHECK-NEXT: bc 12, 20, .LBB12_2
250 ; CHECK-NEXT: mfvsrd 4, 1
251 ; CHECK-NEXT: cmpld 1, 4, 3
252 ; CHECK-NEXT: bc 12, 20, .LBB12_3
255253 ; CHECK-NEXT: # %bb.1:
254 ; CHECK-NEXT: crand 20, 2, 4
255 ; CHECK-NEXT: bc 12, 20, .LBB12_3
256 ; CHECK-NEXT: # %bb.2:
256257 ; CHECK-NEXT: vmr 2, 4
257 ; CHECK-NEXT: .LBB12_2:
258 ; CHECK-NEXT: .LBB12_3:
258259 ; CHECK-NEXT: xxswapd 0, 34
259260 ; CHECK-NEXT: mfvsrd 4, 34
260261 ; CHECK-NEXT: mfvsrd 3, 0