[llvm] [CostModel][X86] Add basic AVX512 Intrinsic::masked_compresstore cost tables (PR #226240)

via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 5 03:18:16 PDT 2026


================
@@ -6000,32 +6000,59 @@ X86TTIImpl::getMemIntrinsicInstrCost(const MemIntrinsicCostAttributes &MICA,
   case Intrinsic::masked_load:
   case Intrinsic::masked_store:
     return getMaskedMemoryOpCost(MICA, CostKind);
+  case Intrinsic::masked_compressstore:
+    // Fallback to scalarization for slow compressstore targets (e.g. znver4).
+    if (ST->isVecCompressStoreSlow())
+      return BaseT::getMemIntrinsicInstrCost(MICA, CostKind);
+    break;
   }
 
   static const CostKindTblEntry AVX512VBMI2CostTable[] = {
-    { Intrinsic::masked_expandload,  MVT::v16i8,  { 2, 7, 1, 3 } },
-    { Intrinsic::masked_expandload,  MVT::v32i8,  { 2, 8, 1, 3 } },
-    { Intrinsic::masked_expandload,  MVT::v64i8,  { 2, 9, 1, 3 } },
+    { Intrinsic::masked_expandload,    MVT::v16i8,  { 2, 7, 1, 3 } },
+    { Intrinsic::masked_expandload,    MVT::v32i8,  { 2, 8, 1, 3 } },
+    { Intrinsic::masked_expandload,    MVT::v64i8,  { 2, 9, 1, 3 } },
+
+    { Intrinsic::masked_expandload,    MVT::v8i16,  { 2, 7, 1, 3 } },
+    { Intrinsic::masked_expandload,    MVT::v16i16, { 2, 8, 1, 3 } },
+    { Intrinsic::masked_expandload,    MVT::v32i16, { 2, 9, 1, 3 } },
+
+    { Intrinsic::masked_compressstore, MVT::v16i8,  { 3,10, 1, 7 } },
+    { Intrinsic::masked_compressstore, MVT::v32i8,  { 3,11, 1, 7 } },
+    { Intrinsic::masked_compressstore, MVT::v64i8,  { 3,12, 1, 8 } },
 
-    { Intrinsic::masked_expandload,  MVT::v8i16,  { 2, 7, 1, 3 } },
-    { Intrinsic::masked_expandload,  MVT::v16i16, { 2, 8, 1, 3 } },
-    { Intrinsic::masked_expandload,  MVT::v32i16, { 2, 9, 1, 3 } },
+    { Intrinsic::masked_compressstore, MVT::v8i16,  { 3,10, 1, 7 } },
+    { Intrinsic::masked_compressstore, MVT::v16i16, { 3,11, 1, 7 } },
+    { Intrinsic::masked_compressstore, MVT::v32i16, { 3,12, 1, 8 } },
----------------
ganeshgit wrote:

Masked compress store is microcoded in zen5 and I observe 

{ v4f32/v4i32/v2f64/v2i64, { 3, 16, 1, 7 } },
{ v8f32/v8i32/v4f64/v4i64, { 3, 18, 1, 7 } },
{ v16f32/v8f64/v8i64,         { 3, 19, 1, 8 } },
{ v16i32,                             { 3, 18, 1, 8 } },

This also is what uops.info points to. @222rohan also verified it. 



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


More information about the llvm-commits mailing list