Index: llvm/lib/Analysis/ValueTracking.cpp =================================================================== --- llvm/lib/Analysis/ValueTracking.cpp +++ llvm/lib/Analysis/ValueTracking.cpp @@ -4619,6 +4619,14 @@ Known.SignBit = std::nullopt; break; } + case Instruction::FPTrunc: { + KnownFPClass KnownSrc; + computeKnownFPClass(Op->getOperand(0), DemandedElts, + InterestedClasses, KnownSrc, Depth + 1, Q, TLI); + if (KnownSrc.isKnownNeverNaN()) + Known.knownNot(fcNan); + break; + } case Instruction::SIToFP: case Instruction::UIToFP: { // Cannot produce nan Index: llvm/test/Transforms/Attributor/nofpclass-fptrunc.ll =================================================================== --- llvm/test/Transforms/Attributor/nofpclass-fptrunc.ll +++ llvm/test/Transforms/Attributor/nofpclass-fptrunc.ll @@ -12,7 +12,7 @@ } define float @ret_fptrunc_nonan(double nofpclass(nan) %arg0) { -; CHECK-LABEL: define float @ret_fptrunc_nonan +; CHECK-LABEL: define nofpclass(nan) float @ret_fptrunc_nonan ; CHECK-SAME: (double nofpclass(nan) [[ARG0:%.*]]) #[[ATTR0]] { ; CHECK-NEXT: [[EXT:%.*]] = fptrunc double [[ARG0]] to float ; CHECK-NEXT: ret float [[EXT]] @@ -102,7 +102,7 @@ } define float @ret_fptrunc_nonan_noinf(double nofpclass(nan inf) %arg0) { -; CHECK-LABEL: define float @ret_fptrunc_nonan_noinf +; CHECK-LABEL: define nofpclass(nan) float @ret_fptrunc_nonan_noinf ; CHECK-SAME: (double nofpclass(nan inf) [[ARG0:%.*]]) #[[ATTR0]] { ; CHECK-NEXT: [[EXT:%.*]] = fptrunc double [[ARG0]] to float ; CHECK-NEXT: ret float [[EXT]]