[llvm] [LLVM][DAGCombiner] Fix size calculations in calculateByteProvider. (PR #148425)
Ricardo Jesus via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 14 09:07:27 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:
Thanks, that makes sense. I (incorrectly) assumed that `Index` was used to index into the vector, but it makes a lot more sense that the function actually only cares about the size of the scalar type. Thanks very much for the explanation! :)
https://github.com/llvm/llvm-project/pull/148425
More information about the llvm-commits
mailing list