llvm.org GIT mirror llvm / 249ded3
Rematerialization logic was overly conservative when it comes to loads from fixed stack slots. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47529 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 12 years ago
2 changed file(s) with 55 addition(s) and 20 deletion(s). Raw diff Collapse all Expand all
645645
646646 int FrameIdx = 0;
647647 if (tii_->isLoadFromStackSlot(MI, FrameIdx) &&
648 mf_->getFrameInfo()->isImmutableObjectIndex(FrameIdx)) {
649 // This is a load from fixed stack slot. It can be rematerialized unless
650 // it's re-defined by a two-address instruction.
651 isLoad = true;
652 for (LiveInterval::const_vni_iterator i = li.vni_begin(), e = li.vni_end();
653 i != e; ++i) {
654 const VNInfo *VNI = *i;
655 if (VNI == ValNo)
656 continue;
657 unsigned DefIdx = VNI->def;
658 if (DefIdx == ~1U)
659 continue; // Dead val#.
660 MachineInstr *DefMI = (DefIdx == ~0u)
661 ? NULL : getInstructionFromIndex(DefIdx);
662 if (DefMI && DefMI->isRegReDefinedByTwoAddr(li.reg)) {
663 isLoad = false;
664 return false;
665 }
666 }
648 mf_->getFrameInfo()->isImmutableObjectIndex(FrameIdx))
649 // This is a load from fixed stack slot. It can be rematerialized.
667650 return true;
668 }
669651
670652 if (tii_->isTriviallyReMaterializable(MI)) {
671653 isLoad = TID.isSimpleLoad();
752734 }
753735 FoldOps.push_back(OpIdx);
754736 }
737
738 // Can't fold a load from fixed stack slot into a two address instruction.
739 if (isSS && DefMI && (MRInfo & VirtRegMap::isMod))
740 return false;
755741
756742 MachineInstr *fmi = isSS ? tii_->foldMemoryOperand(*mf_, MI, FoldOps, Slot)
757743 : tii_->foldMemoryOperand(*mf_, MI, FoldOps, DefMI);
0 ; RUN: llvm-as < %s | llc -march=x86 -stats |& grep {Number of re-materialization} | grep 3
1 ; rdar://5761454
2
3 %struct.quad_struct = type { i32, i32, %struct.quad_struct*, %struct.quad_struct*, %struct.quad_struct*, %struct.quad_struct*, %struct.quad_struct* }
4
5 define fastcc %struct.quad_struct* @MakeTree(i32 %size, i32 %center_x, i32 %center_y, i32 %lo_proc, i32 %hi_proc, %struct.quad_struct* %parent, i32 %ct, i32 %level) nounwind {
6 entry:
7 br i1 true, label %bb43.i, label %bb.i
8
9 bb.i: ; preds = %entry
10 ret %struct.quad_struct* null
11
12 bb43.i: ; preds = %entry
13 br i1 true, label %CheckOutside.exit40.i, label %bb11.i38.i
14
15 bb11.i38.i: ; preds = %bb43.i
16 ret %struct.quad_struct* null
17
18 CheckOutside.exit40.i: ; preds = %bb43.i
19 br i1 true, label %CheckOutside.exit30.i, label %bb11.i28.i
20
21 bb11.i28.i: ; preds = %CheckOutside.exit40.i
22 ret %struct.quad_struct* null
23
24 CheckOutside.exit30.i: ; preds = %CheckOutside.exit40.i
25 br i1 true, label %CheckOutside.exit20.i, label %bb11.i18.i
26
27 bb11.i18.i: ; preds = %CheckOutside.exit30.i
28 ret %struct.quad_struct* null
29
30 CheckOutside.exit20.i: ; preds = %CheckOutside.exit30.i
31 br i1 true, label %bb34, label %bb11.i8.i
32
33 bb11.i8.i: ; preds = %CheckOutside.exit20.i
34 ret %struct.quad_struct* null
35
36 bb34: ; preds = %CheckOutside.exit20.i
37 %tmp15.reg2mem.0 = sdiv i32 %size, 2 ; [#uses=7]
38 %tmp85 = sub i32 %center_y, %tmp15.reg2mem.0 ; [#uses=2]
39 %tmp88 = sub i32 %center_x, %tmp15.reg2mem.0 ; [#uses=2]
40 %tmp92 = tail call fastcc %struct.quad_struct* @MakeTree( i32 %tmp15.reg2mem.0, i32 %tmp88, i32 %tmp85, i32 0, i32 %hi_proc, %struct.quad_struct* null, i32 2, i32 0 ) nounwind ; <%struct.quad_struct*> [#uses=0]
41 %tmp99 = add i32 0, %hi_proc ; [#uses=1]
42 %tmp100 = sdiv i32 %tmp99, 2 ; [#uses=1]
43 %tmp110 = tail call fastcc %struct.quad_struct* @MakeTree( i32 %tmp15.reg2mem.0, i32 0, i32 %tmp85, i32 0, i32 %tmp100, %struct.quad_struct* null, i32 3, i32 0 ) nounwind ; <%struct.quad_struct*> [#uses=0]
44 %tmp122 = add i32 %tmp15.reg2mem.0, %center_y ; [#uses=2]
45 %tmp129 = tail call fastcc %struct.quad_struct* @MakeTree( i32 %tmp15.reg2mem.0, i32 0, i32 %tmp122, i32 0, i32 0, %struct.quad_struct* null, i32 1, i32 0 ) nounwind ; <%struct.quad_struct*> [#uses=0]
46 %tmp147 = tail call fastcc %struct.quad_struct* @MakeTree( i32 %tmp15.reg2mem.0, i32 %tmp88, i32 %tmp122, i32 %lo_proc, i32 0, %struct.quad_struct* null, i32 0, i32 0 ) nounwind ; <%struct.quad_struct*> [#uses=0]
47 unreachable
48 }