[PATCH] D148362: [SLP]Fix cost estimation for buildvectors with extracts and/or constants.

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 19 07:53:51 PDT 2023


dmgreen added inline comments.


================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:6976
       }
-      Cost -= TTI.getVectorInstrCost(*EE, EE->getVectorOperandType(), CostKind,
-                                     Idx);
+      Cost -= TTI.getScalarizationOverhead(
+          EE->getVectorOperandType(),
----------------
ABataev wrote:
> dmgreen wrote:
> > Is this to work around the AArch64 cost model?
> Yes, because it has some kind of strange estimation if HasUse == false, the cost of insertelement is 0. Original cost estimation estimates the cost of the deleted extractelement instruction to be 3, while the insertelement instruction to be 0. Actually, it would be good to fix this problem in AArch64 cost model. The cost must be considered free, only if the operand0 is undef/poison, otherwise it is not zero.
> 
> I'm working on another solution, which should generate better shuffles, hope it will fix the regression for AArch64 and improve final emission for other targets.
Yeah that code has always been a bit off. I think once upon a time someone accidentally applied the "zero-lane insert/extract cost 0" to integers as well as floats, and since then it has happened to give better performance in many cases to keep the inaccuracy around. I will look into removing it if I can.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148362/new/

https://reviews.llvm.org/D148362



More information about the llvm-commits mailing list