[llvm] [RISCV] Use APInt in isSimpleVIDSequence to account for index overflow (PR #100072)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 23 02:04:51 PDT 2024
================
@@ -3408,21 +3412,21 @@ static std::optional<VIDSequence> isSimpleVIDSequence(SDValue Op,
// Calculate the step since the last non-undef element, and ensure
// it's consistent across the entire sequence.
unsigned IdxDiff = Idx - PrevElt->second;
- int64_t ValDiff = SignExtend64(*Elt - PrevElt->first, EltSizeInBits);
+ APInt ValDiff = *Elt - PrevElt->first;
// A zero-value value difference means that we're somewhere in the middle
// of a fractional step, e.g. <0,0,0*,0,1,1,1,1>. Wait until we notice a
// step change before evaluating the sequence.
if (ValDiff == 0)
continue;
- int64_t Remainder = ValDiff % IdxDiff;
+ int64_t Remainder = ValDiff.srem(IdxDiff);
----------------
lukel97 wrote:
Idx, PrevIdx, IdxDiff and Remainder operate on the operand indices, not the vid.v sequence, so we can't do them in the smaller SEW type otherwise it overflows. We could still put in them an APInt but it would need to be some arbitrarily wide bit length?
https://github.com/llvm/llvm-project/pull/100072
More information about the llvm-commits
mailing list