[llvm] [SLPVectorizer][X86] Free load cost for stores with constant pointers (PR #118016)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 3 10:57:28 PST 2024
================
@@ -5157,8 +5157,9 @@ InstructionCost X86TTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
InstructionCost Cost = 0;
- // Add a cost for constant load to vector.
- if (Opcode == Instruction::Store && OpInfo.isConstant())
+ // Add a cost for constant load to vector, if pointer is not a constant.
+ if (auto *SI = dyn_cast_or_null<StoreInst>(I);
+ SI && !isa<Constant>(SI->getPointerOperand()) && OpInfo.isConstant())
----------------
antoniofrighetto wrote:
Sorry, isn't this just bad codegen? In principle, we should be able to simply store the constant in the floating-point register, why would we need to load it from memory? GCC seems to catch this: https://godbolt.org/z/6baWMK4cW.
https://github.com/llvm/llvm-project/pull/118016
More information about the llvm-commits
mailing list