[PATCH] D14976: Fixed a failure in cost calculation for vector GEP

Elena Demikhovsky via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 25 23:44:16 PST 2015


delena added inline comments.

================
Comment at: ../include/llvm/Analysis/TargetTransformInfoImpl.h:421
@@ +420,3 @@
+      if (!ConstIdx)
+        if (auto Splat = getSplatValue(*I))
+          ConstIdx = dyn_cast<ConstantInt>(Splat);
----------------
jingyue wrote:
> I don't understand why you use `getSplatValue` here. `getSplatValue` returns the element type only when all the elements in the array/vector are the same. Are you supposed to also protect the cases where the elements are different? 
It may be a vector of constants. In this case the ConstIdx = 0.
For structs, the index is always splat or a scalar constant.

================
Comment at: ../lib/Analysis/VectorUtils.cpp:421
@@ -421,2 +420,3 @@
+const llvm::Value *llvm::getSplatValue(const Value *V) {
   if (auto *CV = dyn_cast<ConstantDataVector>(V))
     return CV->getSplatValue();
----------------
jingyue wrote:
> This if-check seems unnecessary. The one at Line 424 already checks for `ConstantDataVector`. 
Constant and ConstantDataVector are different types. In case of all-zero-vector it is "Constant".


Repository:
  rL LLVM

http://reviews.llvm.org/D14976





More information about the llvm-commits mailing list