Skip to content

[CostModel][X86] Add more realistic v8i64/v16i32 + v8f64/v16f32 add reduction costs - #206124

Merged
RKSimon merged 1 commit into
llvm:mainfrom
RKSimon:x86-avx512-reduce-add-costs
Jun 26, 2026
Merged

[CostModel][X86] Add more realistic v8i64/v16i32 + v8f64/v16f32 add reduction costs#206124
RKSimon merged 1 commit into
llvm:mainfrom
RKSimon:x86-avx512-reduce-add-costs

Conversation

@RKSimon

@RKSimon RKSimon commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Fixes failure to fold to v16i32 reduction on ax512 targets

We still need to determine better CostKind values - but that can wait until #194621 is complete

…eduction costs

Fixes failure to fodl to v16i32 reduction on ax512 targets

We still need to determine better CostKind values - but that can wait until llvm#194621 is complete
@RKSimon RKSimon added the skip-precommit-approval PR for CI feedback, not intended for review label Jun 26, 2026
@RKSimon
RKSimon enabled auto-merge (squash) June 26, 2026 16:24
@llvmorg-github-actions llvmorg-github-actions Bot added backend:X86 llvm:analysis Includes value tracking, cost tables and constant folding llvm:transforms llvm:vectorcombine Cost-based vector combine pass labels Jun 26, 2026
@github-actions

Copy link
Copy Markdown

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff origin/main HEAD --extensions cpp -- llvm/lib/Target/X86/X86TargetTransformInfo.cpp --diff_from_common_commit

⚠️
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing origin/main to the base branch/commit you want to compare against.
⚠️

View the diff from clang-format here.
diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
index 8838fd7e7..06508e947 100644
--- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
+++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
@@ -5672,15 +5672,15 @@ X86TTIImpl::getArithmeticReductionCost(unsigned Opcode, VectorType *ValTy,
   };
 
   static const CostTblEntry AVX512FCostTbl[] = {
-    { ISD::FADD,  MVT::v8f64,   4 },
-    { ISD::FADD,  MVT::v16f32,  5 },
-    { ISD::ADD,   MVT::v8i64,   4 },
-    { ISD::ADD,   MVT::v16i32,  6 },
+      {ISD::FADD, MVT::v8f64, 4},
+      {ISD::FADD, MVT::v16f32, 5},
+      {ISD::ADD, MVT::v8i64, 4},
+      {ISD::ADD, MVT::v16i32, 6},
   };
 
   static const CostTblEntry AVX512BWCostTbl[] = {
-    { ISD::ADD,   MVT::v32i16,  7 },
-    { ISD::ADD,   MVT::v64i8,   4 },
+      {ISD::ADD, MVT::v32i16, 7},
+      {ISD::ADD, MVT::v64i8, 4},
   };
 
   int ISD = TLI->InstructionOpcodeToISD(Opcode);

@RKSimon
RKSimon merged commit 55cc77a into llvm:main Jun 26, 2026
15 of 17 checks passed
@RKSimon
RKSimon deleted the x86-avx512-reduce-add-costs branch June 27, 2026 10:53
LouisLu060211 pushed a commit to LouisLu060211/llvm-project that referenced this pull request Jun 30, 2026
…eduction costs (llvm#206124)

Fixes failure to fold to v16i32 reduction on ax512 targets

We still need to determine better CostKind values - but that can wait until llvm#194621 is complete
maarcosrmz pushed a commit to maarcosrmz/llvm-project that referenced this pull request Jul 1, 2026
…eduction costs (llvm#206124)

Fixes failure to fold to v16i32 reduction on ax512 targets

We still need to determine better CostKind values - but that can wait until llvm#194621 is complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend:X86 llvm:analysis Includes value tracking, cost tables and constant folding llvm:transforms llvm:vectorcombine Cost-based vector combine pass skip-precommit-approval PR for CI feedback, not intended for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant