[llvm] [AArch64][CostModel] Consider the cost of const vector (PR #117539)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 27 06:14:48 PST 2024


================
@@ -10053,8 +10071,10 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
     return Constant::getAllOnesValue(Ty);
   }
 
-  InstructionCost getBuildVectorCost(ArrayRef<Value *> VL, Value *Root) {
-    if ((!Root && allConstant(VL)) || all_of(VL, IsaPred<UndefValue>))
+  InstructionCost getBuildVectorCost(ArrayRef<Value *> VL, Value *Root,
+                                     const TreeEntry *E = nullptr) {
+    if ((!Root && allConstant(VL) && isSplat(VL)) ||
+        all_of(VL, IsaPred<UndefValue>))
       return TTI::TCC_Free;
----------------
alexey-bataev wrote:

I suggest just to call getConstantMaterializationCost here and do an extra analysis for poisons/undefs in this function. If all values are poisons/undefs - return TCC_Free, otherwise return constant materialization cost

https://github.com/llvm/llvm-project/pull/117539


More information about the llvm-commits mailing list