Reduce code duplication resulting from the ConstantVector/ConstantDataVector split.
authorBenjamin Kramer <benny.kra@googlemail.com>
Thu, 13 Feb 2014 16:48:38 +0000 (16:48 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Thu, 13 Feb 2014 16:48:38 +0000 (16:48 +0000)
No intended functionality change.

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

lib/Analysis/CostModel.cpp
lib/Transforms/Vectorize/BBVectorize.cpp
lib/Transforms/Vectorize/LoopVectorize.cpp

index 898da8d0e8d1adfff7551427cdfdebc72d1587d6..8eb5f6857e26e4611d60f8c7434e2092ddcd4f26 100644 (file)
@@ -99,17 +99,9 @@ static TargetTransformInfo::OperandValueKind getOperandInfo(Value *V) {
     TargetTransformInfo::OK_AnyValue;
 
   // Check for a splat of a constant or for a non uniform vector of constants.
-  ConstantDataVector *CDV = 0;
-  if ((CDV = dyn_cast<ConstantDataVector>(V))) {
+  if (isa<ConstantVector>(V) || isa<ConstantDataVector>(V)) {
     OpInfo = TargetTransformInfo::OK_NonUniformConstantValue;
-    if (CDV->getSplatValue() != NULL)
-      OpInfo = TargetTransformInfo::OK_UniformConstantValue;
-  }
-
-  ConstantVector *CV = 0;
-  if ((CV = dyn_cast<ConstantVector>(V))) {
-    OpInfo = TargetTransformInfo::OK_NonUniformConstantValue;
-    if (CV->getSplatValue() != NULL)
+    if (cast<Constant>(V)->getSplatValue() != NULL)
       OpInfo = TargetTransformInfo::OK_UniformConstantValue;
   }
 
index f59dd2160a9d9fff164e4fb2a9e1bd3d8f05ed8d..6ef2020130688fad0121e47947361a0e11a3e89b 100644 (file)
@@ -1043,22 +1043,13 @@ namespace {
           // of constants.
           Value *IOp = I->getOperand(1);
           Value *JOp = J->getOperand(1);
-          if (ConstantDataVector *CDVI = dyn_cast<ConstantDataVector>(IOp)) {
-            if (ConstantDataVector *CDVJ = dyn_cast<ConstantDataVector>(JOp)) {
-              Op2VK = TargetTransformInfo::OK_NonUniformConstantValue;
-              Constant *SplatValue = CDVI->getSplatValue();
-              if (SplatValue != NULL && SplatValue == CDVJ->getSplatValue())
-                Op2VK = TargetTransformInfo::OK_UniformConstantValue;
-            }
-          }
-
-          if (ConstantVector *CVI = dyn_cast<ConstantVector>(IOp)) {
-            if (ConstantVector *CVJ = dyn_cast<ConstantVector>(JOp)) {
-              Op2VK = TargetTransformInfo::OK_NonUniformConstantValue;
-              Constant *SplatValue = CVI->getSplatValue();
-              if (SplatValue != NULL && SplatValue == CVJ->getSplatValue())
-                Op2VK = TargetTransformInfo::OK_UniformConstantValue;
-            }
+          if ((isa<ConstantVector>(IOp) || isa<ConstantDataVector>(IOp)) &&
+              (isa<ConstantVector>(JOp) || isa<ConstantDataVector>(JOp))) {
+            Op2VK = TargetTransformInfo::OK_NonUniformConstantValue;
+            Constant *SplatValue = cast<Constant>(IOp)->getSplatValue();
+            if (SplatValue != NULL &&
+                SplatValue == cast<Constant>(JOp)->getSplatValue())
+              Op2VK = TargetTransformInfo::OK_UniformConstantValue;
           }
         }
       }
index ecbab63acf023529b896de120331bc2c0147aa0f..d7d66e791616827209c3f727eec34ff93d19b2a5 100644 (file)
@@ -5496,13 +5496,9 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I, unsigned VF) {
     // Check for a splat of a constant or for a non uniform vector of constants.
     if (isa<ConstantInt>(Op2))
       Op2VK = TargetTransformInfo::OK_UniformConstantValue;
-    else if (ConstantDataVector *CDV = dyn_cast<ConstantDataVector>(Op2)) {
+    else if (isa<ConstantVector>(Op2) || isa<ConstantDataVector>(Op2)) {
       Op2VK = TargetTransformInfo::OK_NonUniformConstantValue;
-      if (CDV->getSplatValue() != NULL)
-        Op2VK = TargetTransformInfo::OK_UniformConstantValue;
-    } else if (ConstantVector *CV = dyn_cast<ConstantVector>(Op2)) {
-      Op2VK = TargetTransformInfo::OK_NonUniformConstantValue;
-      if (CV->getSplatValue() != NULL)
+      if (cast<Constant>(Op2)->getSplatValue() != NULL)
         Op2VK = TargetTransformInfo::OK_UniformConstantValue;
     }