@@ -5355,14 +5355,17 @@ void computeKnownFPClass(const Value *V, const APInt &DemandedElts,
53555355 const Value *Vec = Op->getOperand (0 );
53565356 const Value *Elt = Op->getOperand (1 );
53575357 auto *CIdx = dyn_cast<ConstantInt>(Op->getOperand (2 ));
5358- // Early out if the index is non-constant or out-of-range.
53595358 unsigned NumElts = DemandedElts.getBitWidth ();
5360- if (!CIdx || CIdx->getValue ().uge (NumElts))
5361- return ;
5359+ APInt DemandedVecElts = DemandedElts;
5360+ bool NeedsElt = true ;
5361+ // If we know the index we are inserting to, clear it from Vec check.
5362+ if (CIdx && CIdx->getValue ().ult (NumElts)) {
5363+ DemandedVecElts.clearBit (CIdx->getZExtValue ());
5364+ NeedsElt = DemandedElts[CIdx->getZExtValue ()];
5365+ }
53625366
5363- unsigned EltIdx = CIdx->getZExtValue ();
53645367 // Do we demand the inserted element?
5365- if (DemandedElts[EltIdx] ) {
5368+ if (NeedsElt ) {
53665369 computeKnownFPClass (Elt, Known, InterestedClasses, Depth + 1 , Q);
53675370 // If we don't know any bits, early out.
53685371 if (Known.isUnknown ())
@@ -5371,10 +5374,8 @@ void computeKnownFPClass(const Value *V, const APInt &DemandedElts,
53715374 Known.KnownFPClasses = fcNone;
53725375 }
53735376
5374- // We don't need the base vector element that has been inserted.
5375- APInt DemandedVecElts = DemandedElts;
5376- DemandedVecElts.clearBit (EltIdx);
5377- if (!!DemandedVecElts) {
5377+ // Do we need anymore elements from Vec?
5378+ if (!DemandedVecElts.isZero ()) {
53785379 KnownFPClass Known2;
53795380 computeKnownFPClass (Vec, DemandedVecElts, InterestedClasses, Known2,
53805381 Depth + 1 , Q);
0 commit comments