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

David Green via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 4 02:17:12 PST 2024


================
@@ -3145,12 +3153,16 @@ InstructionCost AArch64TTIImpl::getCFInstrCost(unsigned Opcode,
   return 0;
 }
 
-InstructionCost AArch64TTIImpl::getVectorInstrCostHelper(const Instruction *I,
-                                                         Type *Val,
-                                                         unsigned Index,
-                                                         bool HasRealUse) {
+InstructionCost AArch64TTIImpl::getVectorInstrCostHelper(
+    std::variant<const Instruction *, const unsigned> InstOrOpcode, Type *Val,
----------------
davemgreen wrote:

I would change this to avoid all the variant code:
```
getVectorInstrCostHelper(unsigned Opcode, Type *Val, unsigned Index, bool HasRealUse, const Instruction *CxtI)
```
If you have a `CxtI`, you can easily get the Opcode from it when calling the function. Then if just needs to check `if (CxtI)` for any checks that use the instruction. It feels like a lot of the added code that has to handle Opcode and I can then fold together into a single version.

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


More information about the llvm-commits mailing list