[llvm-commits] [llvm] r62984 - in /llvm/trunk: lib/Transforms/Scalar/LoopRotation.cpp test/Transforms/LoopRotate/2009-01-25-SingleEntryPhi.ll

Chris Lattner sabre at nondot.org
Sun Jan 25 18:11:30 PST 2009


Author: lattner
Date: Sun Jan 25 20:11:30 2009
New Revision: 62984

URL: http://llvm.org/viewvc/llvm-project?rev=62984&view=rev
Log:
Fix PR3408 by making a non-obvious assumption very obvious, and 
handling the flaw inherent in that assumption.  :)

Added:
    llvm/trunk/test/Transforms/LoopRotate/2009-01-25-SingleEntryPhi.ll
Modified:
    llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp?rev=62984&r1=62983&r2=62984&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp Sun Jan 25 20:11:30 2009
@@ -12,7 +12,6 @@
 //===----------------------------------------------------------------------===//
 
 #define DEBUG_TYPE "loop-rotate"
-
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Function.h"
 #include "llvm/Instructions.h"
@@ -26,7 +25,6 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/SmallVector.h"
-
 using namespace llvm;
 
 #define MAX_HEADER_SIZE 16
@@ -178,6 +176,12 @@
   assert(NewHeader && "Unable to determine new loop header");
   assert(L->contains(NewHeader) && !L->contains(Exit) && 
          "Unable to determine loop header and exit blocks");
+  
+  // This code assumes that new header has exactly one predecessor.  Remove any
+  // single entry PHI nodes in it.
+  assert(NewHeader->getSinglePredecessor() &&
+         "New header doesn't have one pred!");
+  FoldSingleEntryPHINodes(NewHeader);
 
   // Copy PHI nodes and other instructions from original header
   // into original pre-header. Unlike original header, original pre-header is

Added: llvm/trunk/test/Transforms/LoopRotate/2009-01-25-SingleEntryPhi.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopRotate/2009-01-25-SingleEntryPhi.ll?rev=62984&view=auto

==============================================================================
--- llvm/trunk/test/Transforms/LoopRotate/2009-01-25-SingleEntryPhi.ll (added)
+++ llvm/trunk/test/Transforms/LoopRotate/2009-01-25-SingleEntryPhi.ll Sun Jan 25 20:11:30 2009
@@ -0,0 +1,21 @@
+; RUN: llvm-as < %s | opt -loop-rotate | llvm-dis
+; PR3408
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
+target triple = "x86_64-unknown-linux-gnu"
+	%struct.Cls = type { i32, i8, [2 x %struct.Cls*], [2 x %struct.Lit*] }
+	%struct.Lit = type { i8 }
+
+define void @picosat_main_bb13.i.i71.outer_bb132.i.i.i.outer(%struct.Cls**, %struct.Cls**, i32 %collect.i.i.i.1.lcssa, i32 %lcollect.i.i.i.2.lcssa, %struct.Cls*** %rhead.tmp.0236.out, i32* %collect.i.i.i.2.out, i32* %lcollect.i.i.i.3.ph.ph.ph.out) nounwind {
+newFuncRoot:
+	br label %codeRepl
+
+bb133.i.i.i.exitStub:		; preds = %codeRepl
+	ret void
+
+bb130.i.i.i:		; preds = %codeRepl
+	%rhead.tmp.0236.lcssa82 = phi %struct.Cls** [ null, %codeRepl ]		; <%struct.Cls**> [#uses=0]
+	br label %codeRepl
+
+codeRepl:		; preds = %bb130.i.i.i, %newFuncRoot
+	br i1 false, label %bb130.i.i.i, label %bb133.i.i.i.exitStub
+}





More information about the llvm-commits mailing list