[llvm] [LLVM][DAGCombiner] Port calculateByteProvider to TypeSize. (PR #148425)
Ricardo Jesus via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 14 08:05:57 PDT 2025
================
@@ -9149,11 +9149,12 @@ calculateByteProvider(SDValue Op, unsigned Index, unsigned Depth,
if (Op.getOpcode() != ISD::LOAD && VectorIndex.has_value())
return std::nullopt;
- unsigned BitWidth = Op.getValueSizeInBits();
- if (BitWidth % 8 != 0)
+ TypeSize BitWidth = Op.getValueSizeInBits();
+ if (!BitWidth.isKnownMultipleOf(8))
return std::nullopt;
- unsigned ByteWidth = BitWidth / 8;
- assert(Index < ByteWidth && "invalid index requested");
+ TypeSize ByteWidth = BitWidth.divideCoefficientBy(8);
+ assert(TypeSize::isKnownLT(TypeSize::getFixed(Index), ByteWidth) &&
+ "invalid index requested");
----------------
rj-jesus wrote:
Apologies if this is obvious, but is there a benefit to using TypeSize here rather than taking `BitWidth`'s `getKnownMinValue()`? (In case it isn't intentional, it also seems that `ByteWidth` may be implicitly converted to unsigned a few lines below in `case ISD::BSWAP`. Once again, I'm sorry if this is obvious and intentional.)
https://github.com/llvm/llvm-project/pull/148425
More information about the llvm-commits
mailing list