Only do FNEG xform when the vector type is a floating point type.
authorEvan Cheng <evan.cheng@apple.com>
Fri, 29 Jun 2007 21:44:35 +0000 (21:44 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Fri, 29 Jun 2007 21:44:35 +0000 (21:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37818 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

index 6fe78cc9cae63d719b772654483aeb67e1e7c779..1780f3728358704f32aa6dcc978ff264d85c9d86 100644 (file)
@@ -1798,13 +1798,15 @@ void SelectionDAGLowering::visitSub(User &I) {
     if (ConstantVector *CV = dyn_cast<ConstantVector>(I.getOperand(0))) {
       const VectorType *DestTy = cast<VectorType>(I.getType());
       const Type *ElTy = DestTy->getElementType();
-      unsigned VL = DestTy->getNumElements();
-      std::vector<Constant*> NZ(VL, ConstantFP::get(ElTy, -0.0));
-      Constant *CNZ = ConstantVector::get(&NZ[0], NZ.size());
-      if (CV == CNZ) {
-        SDOperand Op2 = getValue(I.getOperand(1));
-        setValue(&I, DAG.getNode(ISD::FNEG, Op2.getValueType(), Op2));
-        return;
+      if (ElTy->isFloatingPoint()) {
+        unsigned VL = DestTy->getNumElements();
+        std::vector<Constant*> NZ(VL, ConstantFP::get(ElTy, -0.0));
+        Constant *CNZ = ConstantVector::get(&NZ[0], NZ.size());
+        if (CV == CNZ) {
+          SDOperand Op2 = getValue(I.getOperand(1));
+          setValue(&I, DAG.getNode(ISD::FNEG, Op2.getValueType(), Op2));
+          return;
+        }
       }
     }
   }