[llvm] [CostModel][AArch64] Make extractelement, with fmul user, free whenev… (PR #111479)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 8 06:34:48 PDT 2024


================
@@ -11633,6 +11633,17 @@ InstructionCost BoUpSLP::getTreeCost(ArrayRef<Value *> VectorizedVals) {
   std::optional<DenseMap<Value *, unsigned>> ValueToExtUses;
   DenseMap<const TreeEntry *, DenseSet<Value *>> ExtractsCount;
   SmallPtrSet<Value *, 4> ScalarOpsFromCasts;
+  // Keep track of {Scalar, Index} -> User and User -> {Scalar, Index}.
+  // On AArch64, this helps in fusing a mov instruction, associated with
+  // extractelement, with fmul in the backend so that extractelement is free.
+  DenseMap<std::pair<Value *, unsigned>, SmallVector<Value *, 4>>
+      ScalarAndIdxToUser;
+  DenseMap<Value *, SmallVector<std::pair<Value *, unsigned>, 4>>
+      UserToScalarAndIdx;
----------------
alexey-bataev wrote:

Better to declare these types somewhere and use it across the code

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


More information about the llvm-commits mailing list