[llvm-commits] [llvm] r58184 - in /llvm/trunk: lib/CodeGen/PreAllocSplitting.cpp test/CodeGen/X86/pre-split6.ll

Evan Cheng evan.cheng at apple.com
Sun Oct 26 00:49:04 PDT 2008


Author: evancheng
Date: Sun Oct 26 02:49:03 2008
New Revision: 58184

URL: http://llvm.org/viewvc/llvm-project?rev=58184&view=rev
Log:
Do not shrink wrap live interval in a mbb if it's livein any of its successor blocks. The mbb can be revisited again after all of the successors are processed.

Added:
    llvm/trunk/test/CodeGen/X86/pre-split6.ll
Modified:
    llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp

Modified: llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp?rev=58184&r1=58183&r2=58184&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp (original)
+++ llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp Sun Oct 26 02:49:03 2008
@@ -122,7 +122,7 @@
                              SmallVector<MachineOperand*, 4>&,
                              SmallPtrSet<MachineInstr*, 4>&);
 
-    void ShrinkWrapLiveInterval(VNInfo*, MachineBasicBlock*,
+    void ShrinkWrapLiveInterval(VNInfo*, MachineBasicBlock*, MachineBasicBlock*,
                         MachineBasicBlock*, SmallPtrSet<MachineBasicBlock*, 8>&,
                 DenseMap<MachineBasicBlock*, SmallVector<MachineOperand*, 4> >&,
                   DenseMap<MachineBasicBlock*, SmallPtrSet<MachineInstr*, 4> >&,
@@ -426,15 +426,29 @@
 /// chain to find the new 'kills' and shrink wrap the live interval to the
 /// new kill indices.
 void
-PreAllocSplitting::ShrinkWrapLiveInterval(VNInfo *ValNo,
-                              MachineBasicBlock *MBB, MachineBasicBlock *DefMBB,
+PreAllocSplitting::ShrinkWrapLiveInterval(VNInfo *ValNo, MachineBasicBlock *MBB,
+                          MachineBasicBlock *SuccMBB, MachineBasicBlock *DefMBB,
                                     SmallPtrSet<MachineBasicBlock*, 8> &Visited,
            DenseMap<MachineBasicBlock*, SmallVector<MachineOperand*, 4> > &Uses,
            DenseMap<MachineBasicBlock*, SmallPtrSet<MachineInstr*, 4> > &UseMIs,
                                   SmallVector<MachineBasicBlock*, 4> &UseMBBs) {
-  if (!Visited.insert(MBB))
+  if (Visited.count(MBB))
     return;
 
+  // If live interval is live in another successor path, then we can't process
+  // this block. But we may able to do so after all the successors have been
+  // processed.
+  for (MachineBasicBlock::succ_iterator SI = MBB->succ_begin(),
+         SE = MBB->succ_end(); SI != SE; ++SI) {
+    MachineBasicBlock *SMBB = *SI;
+    if (SMBB == SuccMBB)
+      continue;
+    if (CurrLI->liveAt(LIs->getMBBStartIdx(SMBB)))
+      return;
+  }
+
+  Visited.insert(MBB);
+
   DenseMap<MachineBasicBlock*, SmallVector<MachineOperand*, 4> >::iterator
     UMII = Uses.find(MBB);
   if (UMII != Uses.end()) {
@@ -480,7 +494,8 @@
       // Pred is the def bb and the def reaches other val#s, we must
       // allow the value to be live out of the bb.
       continue;
-    ShrinkWrapLiveInterval(ValNo, Pred, DefMBB, Visited, Uses, UseMIs, UseMBBs);
+    ShrinkWrapLiveInterval(ValNo, Pred, MBB, DefMBB, Visited,
+                           Uses, UseMIs, UseMBBs);
   }
 
   return;
@@ -622,7 +637,7 @@
 
   // Walk up the predecessor chains.
   SmallPtrSet<MachineBasicBlock*, 8> Visited;
-  ShrinkWrapLiveInterval(ValNo, BarrierMBB, DefMBB, Visited,
+  ShrinkWrapLiveInterval(ValNo, BarrierMBB, NULL, DefMBB, Visited,
                          Uses, UseMIs, UseMBBs);
 
   // Remove live range from barrier to the restore. FIXME: Find a better

Added: llvm/trunk/test/CodeGen/X86/pre-split6.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pre-split6.ll?rev=58184&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/X86/pre-split6.ll (added)
+++ llvm/trunk/test/CodeGen/X86/pre-split6.ll Sun Oct 26 02:49:03 2008
@@ -0,0 +1,36 @@
+; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 -pre-alloc-split
+
+ at current_surfaces.b = external global i1		; <i1*> [#uses=1]
+
+declare double @sin(double) nounwind readonly
+
+declare double @asin(double) nounwind readonly
+
+define fastcc void @trace_line(i32 %line) nounwind {
+entry:
+	%.b3 = load i1* @current_surfaces.b		; <i1> [#uses=1]
+	br i1 %.b3, label %bb.nph, label %return
+
+bb.nph:		; preds = %entry
+	%0 = load double* null, align 8		; <double> [#uses=1]
+	%1 = load double* null, align 8		; <double> [#uses=2]
+	%2 = fcmp une double %0, 0.000000e+00		; <i1> [#uses=1]
+	br i1 %2, label %bb9.i, label %bb13.i
+
+bb9.i:		; preds = %bb.nph
+	%3 = tail call double @asin(double 0.000000e+00) nounwind readonly		; <double> [#uses=0]
+	%4 = fdiv double 1.000000e+00, %1		; <double> [#uses=1]
+	%5 = mul double %4, 0.000000e+00		; <double> [#uses=1]
+	%6 = tail call double @asin(double %5) nounwind readonly		; <double> [#uses=0]
+	unreachable
+
+bb13.i:		; preds = %bb.nph
+	%7 = fdiv double 1.000000e+00, %1		; <double> [#uses=1]
+	%8 = tail call double @sin(double 0.000000e+00) nounwind readonly		; <double> [#uses=1]
+	%9 = mul double %7, %8		; <double> [#uses=1]
+	%10 = tail call double @asin(double %9) nounwind readonly		; <double> [#uses=0]
+	unreachable
+
+return:		; preds = %entry
+	ret void
+}





More information about the llvm-commits mailing list