[llvm] [LV] Fix '-1U' bits for smallest type in getSmallestAndWidestTypes (PR #135783)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 16 13:52:01 PDT 2025
================
@@ -4798,17 +4798,16 @@ LoopVectorizationCostModel::getSmallestAndWidestTypes() {
// if there are no loads/stores in the loop. In this case, check through the
// reduction variables to determine the maximum width.
if (ElementTypesInLoop.empty() && !Legal->getReductionVars().empty()) {
- // Reset MaxWidth so that we can find the smallest type used by recurrences
- // in the loop.
- MaxWidth = -1U;
for (const auto &PhiDescriptorPair : Legal->getReductionVars()) {
const RecurrenceDescriptor &RdxDesc = PhiDescriptorPair.second;
// When finding the min width used by the recurrence we need to account
// for casts on the input operands of the recurrence.
- MaxWidth = std::min<unsigned>(
- MaxWidth, std::min<unsigned>(
+ MinWidth = std::min<unsigned>(
+ MinWidth, std::min<unsigned>(
RdxDesc.getMinWidthCastToRecurrenceTypeInBits(),
RdxDesc.getRecurrenceType()->getScalarSizeInBits()));
+ MaxWidth = std::max<unsigned>(
----------------
fhahn wrote:
Yes, it seems like the new behavior matches the expectations.
https://github.com/llvm/llvm-project/pull/135783
More information about the llvm-commits
mailing list