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

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 25 03:06:47 PST 2024


================
@@ -235,10 +235,17 @@ class AArch64TTIImpl : public BasicTTIImplBase<AArch64TTIImpl> {
   bool useNeonVector(const Type *Ty) const;
 
   InstructionCost
-  getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
-                  unsigned AddressSpace, TTI::TargetCostKind CostKind,
-                  TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
-                  const Instruction *I = nullptr);
+  getConstVectCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
+                   unsigned AddressSpace, TTI::TargetCostKind CostKind,
+                   TTI::OperandValueInfo OpInfo, const Instruction *I,
+                   const bool SrcIsConstVect, InstructionCost ScalarCost);
+
+  InstructionCost getMemoryOpCost(
+      unsigned Opcode, Type *Src, MaybeAlign Alignment, unsigned AddressSpace,
+      TTI::TargetCostKind CostKind,
+      TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
+      const Instruction *I = nullptr, const bool SrcIsConstVect = false,
+      InstructionCost ScalarCost = 10000);
----------------
david-arm wrote:

I'm not sure we really want to be introducing magic values like this. We've been trying to remove/avoid this in the last few years now that InstructionCost can be marked as invalid. In fact, you can probably condense the two operands into one:

```
  InstructionCost getMemoryOpCost(
      unsigned Opcode, Type *Src, MaybeAlign Alignment, unsigned AddressSpace,
      TTI::TargetCostKind CostKind,
      TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
      const Instruction *I = nullptr,
      InstructionCost ScalarCost = InstructionCost::getInvalid());
```

That way in the implementation of `getMemoryOpCost` you can ask if the cost is valid or not, which has the same effect as `SrcIsConstVect`.

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


More information about the llvm-commits mailing list