[llvm] [AArch64] Guard against getRegisterBitWidth returning zero in vector instr cost. (PR #117749)
Sushant Gokhale via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 26 21:22:30 PST 2024
================
@@ -3248,19 +3248,18 @@ InstructionCost AArch64TTIImpl::getVectorInstrCostHelper(
// Check if the extractelement user is scalar fmul.
auto IsUserFMulScalarTy = [](const Value *EEUser) {
// Check if the user is scalar fmul.
- const auto *BO = dyn_cast_if_present<BinaryOperator>(EEUser);
+ const auto *BO = dyn_cast<BinaryOperator>(EEUser);
return BO && BO->getOpcode() == BinaryOperator::FMul &&
!BO->getType()->isVectorTy();
};
// Check if the extract index is from lane 0 or lane equivalent to 0 for a
// certain scalar type and a certain vector register width.
- auto IsExtractLaneEquivalentToZero = [&](const unsigned &Idx,
- const unsigned &EltSz) {
+ auto IsExtractLaneEquivalentToZero = [&](unsigned Idx, unsigned EltSz) {
auto RegWidth =
getRegisterBitWidth(TargetTransformInfo::RGK_FixedWidthVector)
.getFixedValue();
- return (Idx == 0 || (Idx * EltSz) % RegWidth == 0);
+ return RegWidth != 0 && (Idx == 0 || (Idx * EltSz) % RegWidth == 0);
----------------
sushgokh wrote:
Could you please elaborate why the `RegWidth` can be 0 in sme streaming functions? If there is some article which I can read about, you can point that.
Can you push the check inside?
`return Idx == 0 || (RegWidth != 0 && (Idx * EltSz) % RegWidth == 0)`
https://github.com/llvm/llvm-project/pull/117749
More information about the llvm-commits
mailing list