diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 0a460786d00ea..bde30060736c1 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -5604,19 +5604,20 @@ void computeKnownFPClass(const Value *V, const APInt &DemandedElts, // Look through extract element. If the index is non-constant or // out-of-range demand all elements, otherwise just the extracted element. const Value *Vec = Op->getOperand(0); - const Value *Idx = Op->getOperand(1); - auto *CIdx = dyn_cast(Idx); + APInt DemandedVecElts; if (auto *VecTy = dyn_cast(Vec->getType())) { unsigned NumElts = VecTy->getNumElements(); - APInt DemandedVecElts = APInt::getAllOnes(NumElts); + DemandedVecElts = APInt::getAllOnes(NumElts); + auto *CIdx = dyn_cast(Op->getOperand(1)); if (CIdx && CIdx->getValue().ult(NumElts)) DemandedVecElts = APInt::getOneBitSet(NumElts, CIdx->getZExtValue()); - return computeKnownFPClass(Vec, DemandedVecElts, InterestedClasses, Known, - Q, Depth + 1); + } else { + DemandedVecElts = APInt(1, 1); } - break; + return computeKnownFPClass(Vec, DemandedVecElts, InterestedClasses, Known, + Q, Depth + 1); } case Instruction::InsertElement: { if (isa(Op->getType())) diff --git a/llvm/test/Transforms/Attributor/nofpclass.ll b/llvm/test/Transforms/Attributor/nofpclass.ll index cfc7877383881..8dd2aa34f94cd 100644 --- a/llvm/test/Transforms/Attributor/nofpclass.ll +++ b/llvm/test/Transforms/Attributor/nofpclass.ll @@ -1474,7 +1474,7 @@ define float @returned_extractelement_index_oob(<4 x float> nofpclass(nan) %vec) define float @returned_extractelement_scalable( nofpclass(nan) %vec) { ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) -; CHECK-LABEL: define float @returned_extractelement_scalable +; CHECK-LABEL: define nofpclass(nan) float @returned_extractelement_scalable ; CHECK-SAME: ( nofpclass(nan) [[VEC:%.*]]) #[[ATTR3]] { ; CHECK-NEXT: [[EXTRACT:%.*]] = extractelement [[VEC]], i32 0 ; CHECK-NEXT: ret float [[EXTRACT]]