@@ -5355,14 +5355,17 @@ void computeKnownFPClass(const Value *V, const APInt &DemandedElts,
5355
5355
const Value *Vec = Op->getOperand (0 );
5356
5356
const Value *Elt = Op->getOperand (1 );
5357
5357
auto *CIdx = dyn_cast<ConstantInt>(Op->getOperand (2 ));
5358
- // Early out if the index is non-constant or out-of-range.
5359
5358
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
+ }
5362
5366
5363
- unsigned EltIdx = CIdx->getZExtValue ();
5364
5367
// Do we demand the inserted element?
5365
- if (DemandedElts[EltIdx] ) {
5368
+ if (NeedsElt ) {
5366
5369
computeKnownFPClass (Elt, Known, InterestedClasses, Depth + 1 , Q);
5367
5370
// If we don't know any bits, early out.
5368
5371
if (Known.isUnknown ())
@@ -5371,10 +5374,8 @@ void computeKnownFPClass(const Value *V, const APInt &DemandedElts,
5371
5374
Known.KnownFPClasses = fcNone;
5372
5375
}
5373
5376
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 ()) {
5378
5379
KnownFPClass Known2;
5379
5380
computeKnownFPClass (Vec, DemandedVecElts, InterestedClasses, Known2,
5380
5381
Depth + 1 , Q);
0 commit comments