llvm.org GIT mirror llvm / f62ce37
Avoid putting a split past the end of the live range; always shrink wrap live interval in the barrier mbb. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58309 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 11 years ago
3 changed file(s) with 94 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
108108 SmallPtrSet&, unsigned&);
109109
110110 MachineBasicBlock::iterator
111 findRestorePoint(MachineBasicBlock*, MachineInstr*,
111 findRestorePoint(MachineBasicBlock*, MachineInstr*, unsigned,
112112 SmallPtrSet&, unsigned&);
113113
114114 void RecordSplit(unsigned, unsigned, unsigned, int);
202202 /// found.
203203 MachineBasicBlock::iterator
204204 PreAllocSplitting::findRestorePoint(MachineBasicBlock *MBB, MachineInstr *MI,
205 unsigned LastIdx,
205206 SmallPtrSet &RefsInMBB,
206207 unsigned &RestoreIndex) {
207208 MachineBasicBlock::iterator Pt = MBB->end();
208
209 // Go bottom up if RefsInMBB is empty.
210 if (RefsInMBB.empty()) {
209 unsigned EndIdx = LIs->getMBBEndIdx(MBB);
210
211 // Go bottom up if RefsInMBB is empty and the end of the mbb isn't beyond
212 // the last index in the live range.
213 if (RefsInMBB.empty() && LastIdx >= EndIdx) {
211214 MachineBasicBlock::iterator MII = MBB->end();
212215 MachineBasicBlock::iterator EndPt = MI;
213216 do {
223226 } else {
224227 MachineBasicBlock::iterator MII = MI;
225228 MII = ++MII;
229 // FIXME: Limit the number of instructions to examine to reduce
230 // compile time?
226231 while (MII != MBB->end()) {
227232 unsigned Index = LIs->getInstructionIndex(MII);
233 if (Index > LastIdx)
234 break;
228235 unsigned Gap = LIs->findGapBeforeInstr(Index);
229236 if (Gap) {
230237 Pt = MII;
437444 // If live interval is live in another successor path, then we can't process
438445 // this block. But we may able to do so after all the successors have been
439446 // processed.
440 for (MachineBasicBlock::succ_iterator SI = MBB->succ_begin(),
441 SE = MBB->succ_end(); SI != SE; ++SI) {
442 MachineBasicBlock *SMBB = *SI;
443 if (SMBB == SuccMBB)
444 continue;
445 if (CurrLI->liveAt(LIs->getMBBStartIdx(SMBB)))
446 return;
447 if (MBB != BarrierMBB) {
448 for (MachineBasicBlock::succ_iterator SI = MBB->succ_begin(),
449 SE = MBB->succ_end(); SI != SE; ++SI) {
450 MachineBasicBlock *SMBB = *SI;
451 if (SMBB == SuccMBB)
452 continue;
453 if (CurrLI->liveAt(LIs->getMBBStartIdx(SMBB)))
454 return;
455 }
447456 }
448457
449458 Visited.insert(MBB);
535544 // Find a point to restore the value after the barrier.
536545 unsigned RestoreIndex;
537546 MachineBasicBlock::iterator RestorePt =
538 findRestorePoint(BarrierMBB, Barrier, RefsInMBB, RestoreIndex);
547 findRestorePoint(BarrierMBB, Barrier, LR->end, RefsInMBB, RestoreIndex);
539548 if (RestorePt == BarrierMBB->end())
540549 return false;
541550
0 ; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 -pre-alloc-split -stats |& \
1 ; RUN: grep {pre-alloc-split} | grep {Number of intervals split} | grep 1
2
3 @current_surfaces.b = external global i1 ; [#uses=1]
4
5 declare double @asin(double) nounwind readonly
6
7 declare double @tan(double) nounwind readonly
8
9 define fastcc void @trace_line(i32 %line) nounwind {
10 entry:
11 %.b3 = load i1* @current_surfaces.b ; [#uses=1]
12 br i1 %.b3, label %bb, label %return
13
14 bb: ; preds = %bb9.i, %entry
15 %.rle4 = phi double [ %7, %bb9.i ], [ 0.000000e+00, %entry ] ; [#uses=1]
16 %0 = load double* null, align 8 ; [#uses=3]
17 %1 = fcmp une double %0, 0.000000e+00 ; [#uses=1]
18 br i1 %1, label %bb9.i, label %bb13.i
19
20 bb9.i: ; preds = %bb
21 %2 = sub double %.rle4, %0 ; [#uses=0]
22 %3 = tail call double @asin(double 0.000000e+00) nounwind readonly ; [#uses=0]
23 %4 = mul double 0.000000e+00, %0 ; [#uses=1]
24 %5 = tail call double @tan(double 0.000000e+00) nounwind readonly ; [#uses=0]
25 %6 = mul double %4, 0.000000e+00 ; [#uses=1]
26 %7 = add double %6, 0.000000e+00 ; [#uses=1]
27 br i1 false, label %return, label %bb
28
29 bb13.i: ; preds = %bb
30 unreachable
31
32 return: ; preds = %bb9.i, %entry
33 ret void
34 }
0 ; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 -pre-alloc-split -stats |& \
1 ; RUN: grep {pre-alloc-split} | grep {Number of intervals split} | grep 1
2
3 @current_surfaces.b = external global i1 ; [#uses=1]
4
5 declare double @sin(double) nounwind readonly
6
7 declare double @asin(double) nounwind readonly
8
9 declare double @tan(double) nounwind readonly
10
11 define fastcc void @trace_line(i32 %line) nounwind {
12 entry:
13 %.b3 = load i1* @current_surfaces.b ; [#uses=1]
14 br i1 %.b3, label %bb, label %return
15
16 bb: ; preds = %bb9.i, %entry
17 %.rle4 = phi double [ %8, %bb9.i ], [ 0.000000e+00, %entry ] ; [#uses=1]
18 %0 = load double* null, align 8 ; [#uses=3]
19 %1 = fcmp une double %0, 0.000000e+00 ; [#uses=1]
20 br i1 %1, label %bb9.i, label %bb13.i
21
22 bb9.i: ; preds = %bb
23 %2 = sub double %.rle4, %0 ; [#uses=0]
24 %3 = tail call double @asin(double 0.000000e+00) nounwind readonly ; [#uses=0]
25 %4 = tail call double @sin(double 0.000000e+00) nounwind readonly ; [#uses=1]
26 %5 = mul double %4, %0 ; [#uses=1]
27 %6 = tail call double @tan(double 0.000000e+00) nounwind readonly ; [#uses=0]
28 %7 = mul double %5, 0.000000e+00 ; [#uses=1]
29 %8 = add double %7, 0.000000e+00 ; [#uses=1]
30 br i1 false, label %return, label %bb
31
32 bb13.i: ; preds = %bb
33 unreachable
34
35 return: ; preds = %bb9.i, %entry
36 ret void
37 }