Index: lib/Analysis/ValueTracking.cpp =================================================================== --- lib/Analysis/ValueTracking.cpp +++ lib/Analysis/ValueTracking.cpp @@ -4395,14 +4395,14 @@ if (FMF.noNaNs()) return true; - if (auto *C = dyn_cast(V)) - return !C->isNaN(); + if (auto *C = dyn_cast(V)) + return C->getType()->isFPOrFPVectorTy() && !C->isNaN(); return false; } static bool isKnownNonZero(const Value *V) { - if (auto *C = dyn_cast(V)) - return !C->isZero(); + if (auto *C = dyn_cast(V)) + return C->getType()->isFPOrFPVectorTy() && !C->isZeroValue(); return false; } Index: unittests/Analysis/ValueTrackingTest.cpp =================================================================== --- unittests/Analysis/ValueTrackingTest.cpp +++ unittests/Analysis/ValueTrackingTest.cpp @@ -77,6 +77,42 @@ expectPattern({SPF_FMINNUM, SPNB_RETURNS_NAN, false}); } +TEST_F(MatchSelectPatternTest, VectorFMin) { + parseAssembly( + "define <4 x float> @test(<4 x float> %a) {\n" + " %1 = fcmp ule <4 x float> %a, \n" + " \n" + " %A = select <4 x i1> %1, <4 x float> %a,\n" + " <4 x float> \n" + " ret <4 x float> %A\n" + "}\n"); + expectPattern({SPF_FMINNUM, SPNB_RETURNS_NAN, false}); +} + +TEST_F(MatchSelectPatternTest, VectorNotFMinNaN) { + parseAssembly( + "define <4 x float> @test(<4 x float> %a) {\n" + " %1 = fcmp ule <4 x float> %a, \n" + " \n" + " %A = select <4 x i1> %1, <4 x float> %a,\n" + " <4 x float> \n" + " ret <4 x float> %A\n" + "}\n"); + expectPattern({SPF_UNKNOWN, SPNB_NA, false}); +} + +TEST_F(MatchSelectPatternTest, VectorNotFMinZero) { + parseAssembly( + "define <4 x float> @test(<4 x float> %a) {\n" + " %1 = fcmp ule <4 x float> %a, \n" + " \n" + " %A = select <4 x i1> %1, <4 x float> %a,\n" + " <4 x float> \n" + " ret <4 x float> %A\n" + "}\n"); + expectPattern({SPF_UNKNOWN, SPNB_NA, false}); +} + TEST_F(MatchSelectPatternTest, SimpleFMax) { parseAssembly( "define float @test(float %a) {\n"