[llvm] [ExpandReductions] Add support for non-pow2 vector counts (PR #208738)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 21 03:38:40 PDT 2026
================
@@ -112,11 +127,18 @@ bool expandReductions(Function &F, const TargetTransformInfo *TTI,
Value *Vec = II->getArgOperand(0);
auto *FTy = cast<FixedVectorType>(Vec->getType());
unsigned NumElts = FTy->getNumElements();
- if (!isPowerOf2_32(NumElts))
- continue;
if (FTy->getElementType() == Builder.getInt1Ty()) {
- Rdx = Builder.CreateBitCast(Vec, Builder.getIntNTy(NumElts));
+ unsigned Width = PowerOf2Ceil(NumElts);
+ if (Width != NumElts) {
+ Constant *Identity = ID == Intrinsic::vector_reduce_and
----------------
arsenm wrote:
We should have a more proper method to get the identity value for a given operation. Doesn't that exist already?
https://github.com/llvm/llvm-project/pull/208738
More information about the llvm-commits
mailing list