[llvm] r246379 - Revert "New interface function is added to VectorUtils Value *getSplatValue(Value *Val); "

Renato Golin via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 30 03:05:31 PDT 2015


Author: rengolin
Date: Sun Aug 30 05:05:30 2015
New Revision: 246379

URL: http://llvm.org/viewvc/llvm-project?rev=246379&view=rev
Log:
Revert "New interface function is added to VectorUtils Value *getSplatValue(Value *Val);"

This reverts commit r246371, as it cause a rather obscure bug in AArch64
test-suite paq8p (time outs, seg-faults). I'll investigate it before
reapplying.

Modified:
    llvm/trunk/include/llvm/Analysis/VectorUtils.h
    llvm/trunk/lib/Analysis/VectorUtils.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Modified: llvm/trunk/include/llvm/Analysis/VectorUtils.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/VectorUtils.h?rev=246379&r1=246378&r2=246379&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/VectorUtils.h (original)
+++ llvm/trunk/include/llvm/Analysis/VectorUtils.h Sun Aug 30 05:05:30 2015
@@ -79,11 +79,6 @@ Value *getStrideFromPointer(Value *Ptr,
 /// from the vector.
 Value *findScalarElement(Value *V, unsigned EltNo);
 
-/// \brief Get splat value if the input is a splat vector or return nullptr.
-/// The value may be extracted from a splat constants vector or from
-/// a sequence of instructions that broadcast a single value into a vector.
-Value *getSplatValue(Value *V);
-
 } // llvm namespace
 
 #endif

Modified: llvm/trunk/lib/Analysis/VectorUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/VectorUtils.cpp?rev=246379&r1=246378&r2=246379&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/VectorUtils.cpp (original)
+++ llvm/trunk/lib/Analysis/VectorUtils.cpp Sun Aug 30 05:05:30 2015
@@ -18,8 +18,6 @@
 #include "llvm/IR/GetElementPtrTypeIterator.h"
 #include "llvm/IR/PatternMatch.h"
 #include "llvm/IR/Value.h"
-#include "llvm/IR/Constants.h"
-
 using namespace llvm;
 using namespace llvm::PatternMatch;
 
@@ -408,27 +406,3 @@ Value *llvm::findScalarElement(Value *V,
   // Otherwise, we don't know.
   return nullptr;
 }
-
-/// \brief Get splat value if the input is a splat vector or return nullptr.
-/// The value may be extracted from a splat constants vector or from
-/// a sequence of instructions that broadcast a single value into a vector.
-llvm::Value *llvm::getSplatValue(Value *V) {
-  llvm::ConstantDataVector *CV = dyn_cast<llvm::ConstantDataVector>(V);
-  if (CV)
-    return CV->getSplatValue();
-  llvm::ShuffleVectorInst *ShuffleInst = dyn_cast<llvm::ShuffleVectorInst>(V);
-  if (!ShuffleInst)
-    return nullptr;
-  // All-zero (our undef) shuffle mask elements.
-  for (int i : ShuffleInst->getShuffleMask())
-    if (i != 0 && i != -1)
-      return nullptr;
-  // The first shuffle source is 'insertelement' with index 0.
-  llvm::InsertElementInst *InsertEltInst =
-    dyn_cast<llvm::InsertElementInst>(ShuffleInst->getOperand(0));
-  if (!InsertEltInst || !isa<ConstantInt>(InsertEltInst->getOperand(2)) ||
-      !cast<ConstantInt>(InsertEltInst->getOperand(2))->isNullValue())
-    return nullptr;
-
-  return InsertEltInst->getOperand(1);
-}

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=246379&r1=246378&r2=246379&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Sun Aug 30 05:05:30 2015
@@ -22,7 +22,6 @@
 #include "llvm/Analysis/ConstantFolding.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/ValueTracking.h"
-#include "llvm/Analysis/VectorUtils.h"
 #include "llvm/CodeGen/FastISel.h"
 #include "llvm/CodeGen/FunctionLoweringInfo.h"
 #include "llvm/CodeGen/GCMetadata.h"
@@ -3151,32 +3150,37 @@ static bool getUniformBase(Value *& Ptr,
                            SelectionDAGBuilder* SDB) {
 
   assert(Ptr->getType()->isVectorTy() && "Unexpected pointer type");
-  GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(Ptr);
-  if (!GEP || GEP->getNumOperands() > 2)
+  GetElementPtrInst *Gep = dyn_cast<GetElementPtrInst>(Ptr);
+  if (!Gep || Gep->getNumOperands() > 2)
     return false;
-  Value *GEPPtrs = GEP->getPointerOperand();
-  if (!(Ptr = getSplatValue(GEPPtrs)))
+  ShuffleVectorInst *ShuffleInst = 
+    dyn_cast<ShuffleVectorInst>(Gep->getPointerOperand());
+  if (!ShuffleInst || !ShuffleInst->getMask()->isNullValue() ||
+      cast<Instruction>(ShuffleInst->getOperand(0))->getOpcode() !=
+      Instruction::InsertElement)
     return false;
 
+  Ptr = cast<InsertElementInst>(ShuffleInst->getOperand(0))->getOperand(1);
+
   SelectionDAG& DAG = SDB->DAG;
   const TargetLowering &TLI = DAG.getTargetLoweringInfo();
   // Check is the Ptr is inside current basic block
   // If not, look for the shuffle instruction
   if (SDB->findValue(Ptr))
     Base = SDB->getValue(Ptr);
-  else if (SDB->findValue(GEPPtrs)) {
-    SDValue GEPPtrsVal = SDB->getValue(GEPPtrs);
-    SDLoc sdl = GEPPtrsVal;
-    EVT IdxVT = TLI.getVectorIdxTy(DAG.getDataLayout());
-    Base = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, sdl,
-                       GEPPtrsVal.getValueType().getScalarType(), GEPPtrsVal,
-                       DAG.getConstant(0, sdl, IdxVT));
+  else if (SDB->findValue(ShuffleInst)) {
+    SDValue ShuffleNode = SDB->getValue(ShuffleInst);
+    SDLoc sdl = ShuffleNode;
+    Base = DAG.getNode(
+        ISD::EXTRACT_VECTOR_ELT, sdl,
+        ShuffleNode.getValueType().getScalarType(), ShuffleNode,
+        DAG.getConstant(0, sdl, TLI.getVectorIdxTy(DAG.getDataLayout())));
     SDB->setValue(Ptr, Base);
   }
   else
     return false;
 
-  Value *IndexVal = GEP->getOperand(1);
+  Value *IndexVal = Gep->getOperand(1);
   if (SDB->findValue(IndexVal)) {
     Index = SDB->getValue(IndexVal);
 




More information about the llvm-commits mailing list