[llvm] [X86][CostModel] Add per-shape gather/scatter cost tables for AMD znver4+ (PR #199488)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 8 02:37:57 PDT 2026
================
@@ -721,6 +721,17 @@ def TuningFastGather
: SubtargetFeature<"fast-gather", "HasFastGather", "true",
"Indicates if gather is reasonably fast (this is true for Skylake client and all AVX-512 CPUs)">;
+// Use AMD Zen-tuned cost tables for masked gather/scatter intrinsics in the
+// X86 TargetTransformInfo cost model. Refines the flat overhead used by other
+// AVX-512 targets with per-element-type/per-VL costs measured on znver4 and
+// znver5. Inherited automatically by every znver4+ CPU via ZN4Tuning; not
+// applied to pre-AVX-512 Zen parts (znver1..3), which take the scalarise
+// path for masked gather anyway.
+def TuningPreferAMDZenGSCost
----------------
ganeshgit wrote:
This is a function of Vector Factor, Data Type, and the instruction. So, deducing a number from the latency of scheduler is not applicable directly. It seems more of a Feature Tuning. What I thought was something of below kind which can grow as and when required. (Can be even made as a table lookup later).
static const UnifiedVendorCostTable[] = {
// Subtarget | ISD Opcode | Base Type | VF | Cost
// --- Generation 1 Costs ---
{ ST_Gen1, <values>},
{ ST_Gen1, <values> },
// --- Generation 2 Costs ---
{ ST_Gen2, <values> },
{ ST_Gen2, <values> },
// --- Global Overrides (Optional Example) ---
{ ST_All, ISD::SDIV, MVT::i32, 1, 20 }
};
Given that, I think the code changes looks okay now. If we don't want the Unified Vendor Cost Table, we can go back to Sumukh's first patch having TuningPreferAMDGSCostTable!
https://github.com/llvm/llvm-project/pull/199488
More information about the llvm-commits
mailing list