diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -7062,13 +7062,13 @@ } } - // If none of the above worked, but there are no NaNs, then expand to - // a compare/select sequence. This is required for correctness since - // InstCombine might have canonicalized a fcmp+select sequence to a + // If none of the above worked for scalar operands, but there are no NaNs, + // then expand to a compare/select sequence. This is required for correctness + // since InstCombine might have canonicalized a fcmp+select sequence to a // FMINNUM/FMAXNUM node. If we were to fall through to the default // expansion to libcall, we might introduce a link-time dependency // on libm into a file that originally did not have one. - if (Node->getFlags().hasNoNaNs()) { + if (!VT.isVector() && Node->getFlags().hasNoNaNs()) { ISD::CondCode Pred = Node->getOpcode() == ISD::FMINNUM ? ISD::SETLT : ISD::SETGT; SDValue Op1 = Node->getOperand(0);