[llvm-commits] [polly] r151903 - /polly/trunk/lib/CodeGeneration.cpp

Tobias Grosser grosser at fim.uni-passau.de
Fri Mar 2 03:27:15 PST 2012


Author: grosser
Date: Fri Mar  2 05:27:15 2012
New Revision: 151903

URL: http://llvm.org/viewvc/llvm-project?rev=151903&view=rev
Log:
CodeGen: Sink loop to iterate vector lanes down into copyInstruction

Modified:
    polly/trunk/lib/CodeGeneration.cpp

Modified: polly/trunk/lib/CodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGeneration.cpp?rev=151903&r1=151902&r2=151903&view=diff
==============================================================================
--- polly/trunk/lib/CodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGeneration.cpp Fri Mar  2 05:27:15 2012
@@ -246,9 +246,8 @@
 
   Value *generateScalarLoad(const LoadInst *load, ValueMapT &BBMap);
 
-  /// @brief Load a value (or several values as a vector) from memory.
-  void generateLoad(const LoadInst *Load, ValueMapT &VectorMap,
-                    VectorValueMapT &ScalarMaps);
+  void generateVectorLoad(const LoadInst *Load, ValueMapT &VectorMap,
+                          VectorValueMapT &ScalarMaps);
 
   void copyVectorUnaryInst(const UnaryInstruction *Inst, ValueMapT &BBMap,
                            ValueMapT &VectorMap);
@@ -267,9 +266,8 @@
 
   bool isVectorBlock();
 
-  void copyInstruction(const Instruction *Inst, ValueMapT &BBMap,
-                       ValueMapT &VectorMap, VectorValueMapT &ScalarMaps,
-                       int VectorDimension);
+  void copyInstruction(const Instruction *Inst, ValueMapT &VectorMap,
+                       VectorValueMapT &ScalarMaps);
 
   // Insert a copy of a basic block in the newly generated code.
   //
@@ -535,13 +533,9 @@
   return ScalarLoad;
 }
 
-void BlockGenerator::generateLoad(const LoadInst *Load, ValueMapT &VectorMap,
-                                  VectorValueMapT &ScalarMaps) {
-  if (ScalarMaps.size() == 1) {
-    ScalarMaps[0][Load] = generateScalarLoad(Load, ScalarMaps[0]);
-    return;
-  }
-
+void BlockGenerator::generateVectorLoad(const LoadInst *Load,
+                                          ValueMapT &VectorMap,
+                                          VectorValueMapT &ScalarMaps) {
   Value *NewLoad;
 
   MemoryAccess &Access = Statement.getAccessFor(Load);
@@ -665,53 +659,50 @@
   return getVectorWidth() > 1;
 }
 
-void BlockGenerator::copyInstruction(const Instruction *Inst, ValueMapT &BBMap,
+void BlockGenerator::copyInstruction(const Instruction *Inst,
                                      ValueMapT &VectorMap,
-                                     VectorValueMapT &ScalarMaps,
-                                     int VectorDimension) {
+                                     VectorValueMapT &ScalarMaps) {
   // Terminator instructions control the control flow. They are explicitly
   // expressed in the clast and do not need to be copied.
   if (Inst->isTerminator())
     return;
 
   if (isVectorBlock()) {
-    // If this instruction is already in the vectorMap, a vector instruction
-    // was already issued, that calculates the values of all dimensions. No
-    // need to create any more instructions.
-    if (VectorMap.count(Inst))
-      return;
-
-    // Stores are not in the VectorMap
-    if (isa<StoreInst>(Inst) && VectorDimension > 0)
+    if (const LoadInst *Load = dyn_cast<LoadInst>(Inst)) {
+      generateVectorLoad(Load, VectorMap, ScalarMaps);
       return;
+    }
 
-  }
+    if (hasVectorOperands(Inst, VectorMap)) {
+      if (const StoreInst *Store = dyn_cast<StoreInst>(Inst)) {
+        copyVectorStore(Store, ScalarMaps[0], VectorMap, ScalarMaps);
+        return;
+      }
 
-  if (const LoadInst *Load = dyn_cast<LoadInst>(Inst)) {
-    generateLoad(Load, VectorMap, ScalarMaps);
-    return;
-  }
+      if (const UnaryInstruction *Unary = dyn_cast<UnaryInstruction>(Inst)) {
+        copyVectorUnaryInst(Unary, ScalarMaps[0], VectorMap);
+        return;
+      }
 
-  if (isVectorBlock() && hasVectorOperands(Inst, VectorMap)) {
-    if (const StoreInst *Store = dyn_cast<StoreInst>(Inst)) {
-      copyVectorStore(Store, BBMap, VectorMap, ScalarMaps);
-      return;
-    }
+      if (const BinaryOperator *Binary = dyn_cast<BinaryOperator>(Inst)) {
+        copyVectorBinInst(Binary, ScalarMaps[0], VectorMap);
+        return;
+      }
 
-    if (const UnaryInstruction *UnaryInst = dyn_cast<UnaryInstruction>(Inst)) {
-      copyVectorUnaryInst(UnaryInst, BBMap, VectorMap);
-      return;
+      llvm_unreachable("Cannot issue vector code for this instruction");
     }
 
-    if (const BinaryOperator *BinaryInst = dyn_cast<BinaryOperator>(Inst)) {
-      copyVectorBinInst(BinaryInst, BBMap, VectorMap);
-      return;
-    }
+    for (int VectorLane = 0; VectorLane < getVectorWidth(); VectorLane++)
+      copyInstScalar(Inst, ScalarMaps[VectorLane]);
+    return;
+  }
 
-    llvm_unreachable("Cannot issue vector code for this instruction");
+  if (const LoadInst *Load = dyn_cast<LoadInst>(Inst)) {
+    ScalarMaps[0][Load] = generateScalarLoad(Load, ScalarMaps[0]);
+    return;
   }
 
-  copyInstScalar(Inst, BBMap);
+  copyInstScalar(Inst, ScalarMaps[0]);
 }
 
 void BlockGenerator::copyBB() {
@@ -740,9 +731,7 @@
 
   for (BasicBlock::const_iterator II = BB->begin(), IE = BB->end();
        II != IE; ++II)
-    for (int VectorLane = 0; VectorLane < getVectorWidth(); VectorLane++)
-      copyInstruction(II, ScalarBlockMap[VectorLane], VectorBlockMap,
-                      ScalarBlockMap, VectorLane);
+      copyInstruction(II, VectorBlockMap, ScalarBlockMap);
 }
 
 /// Class to generate LLVM-IR that calculates the value of a clast_expr.





More information about the llvm-commits mailing list