Bug fixes: handle constantexpr insert/extract element operations
authorChris Lattner <sabre@nondot.org>
Wed, 29 Mar 2006 00:11:43 +0000 (00:11 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 29 Mar 2006 00:11:43 +0000 (00:11 +0000)
Handle constantpacked vectors with constantexpr elements.

This fixes CodeGen/Generic/vector-constantexpr.ll

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27241 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

index 3c633266bf90c733118e0682166d600e783e490a..0a694cce1fb45f6012d9dcb495ace7b7c74f04ce 100644 (file)
@@ -507,8 +507,8 @@ public:
   void visitSetLT(User &I) { visitSetCC(I, ISD::SETLT, ISD::SETULT); }
   void visitSetGT(User &I) { visitSetCC(I, ISD::SETGT, ISD::SETUGT); }
 
-  void visitExtractElement(ExtractElementInst &I);
-  void visitInsertElement(InsertElementInst &I);
+  void visitExtractElement(User &I);
+  void visitInsertElement(User &I);
 
   void visitGetElementPtr(User &I);
   void visitCast(User &I);
@@ -586,18 +586,8 @@ SDOperand SelectionDAGLowering::getValue(const Value *V) {
       // the packed constant.
       std::vector<SDOperand> Ops;
       if (ConstantPacked *CP = dyn_cast<ConstantPacked>(C)) {
-        if (MVT::isFloatingPoint(PVT)) {
-          for (unsigned i = 0; i != NumElements; ++i) {
-            const ConstantFP *El = cast<ConstantFP>(CP->getOperand(i));
-            Ops.push_back(DAG.getConstantFP(El->getValue(), PVT));
-          }
-        } else {
-          for (unsigned i = 0; i != NumElements; ++i) {
-            const ConstantIntegral *El = 
-            cast<ConstantIntegral>(CP->getOperand(i));
-            Ops.push_back(DAG.getConstant(El->getRawValue(), PVT));
-          }
-        }
+        for (unsigned i = 0; i != NumElements; ++i)
+          Ops.push_back(getValue(CP->getOperand(i)));
       } else {
         assert(isa<ConstantAggregateZero>(C) && "Unknown packed constant!");
         SDOperand Op;
@@ -1020,7 +1010,7 @@ void SelectionDAGLowering::visitCast(User &I) {
   }
 }
 
-void SelectionDAGLowering::visitInsertElement(InsertElementInst &I) {
+void SelectionDAGLowering::visitInsertElement(User &I) {
   SDOperand InVec = getValue(I.getOperand(0));
   SDOperand InVal = getValue(I.getOperand(1));
   SDOperand InIdx = DAG.getNode(ISD::ZERO_EXTEND, TLI.getPointerTy(),
@@ -1032,7 +1022,7 @@ void SelectionDAGLowering::visitInsertElement(InsertElementInst &I) {
                            InVec, InVal, InIdx, Num, Typ));
 }
 
-void SelectionDAGLowering::visitExtractElement(ExtractElementInst &I) {
+void SelectionDAGLowering::visitExtractElement(User &I) {
   SDOperand InVec = getValue(I.getOperand(0));
   SDOperand InIdx = DAG.getNode(ISD::ZERO_EXTEND, TLI.getPointerTy(),
                                 getValue(I.getOperand(1)));