From c7f52bcee4a63e792bde23051c649d0e2933d643 Mon Sep 17 00:00:00 2001 From: LC Date: Sat, 11 Jul 2026 16:04:39 -0400 Subject: [PATCH] Vector: Centralize masking in InsertScalarFCMPOp Ensures that even if someone threw bogus constants in the upper bits of the immediate, that the special-cased comparison types would still be handled properly. We can move the masking in the AVX variant too, just to be consistent. --- FEXCore/Source/Interface/Core/OpcodeDispatcher/Vector.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/FEXCore/Source/Interface/Core/OpcodeDispatcher/Vector.cpp b/FEXCore/Source/Interface/Core/OpcodeDispatcher/Vector.cpp index 43722bbca..45b911aae 100644 --- a/FEXCore/Source/Interface/Core/OpcodeDispatcher/Vector.cpp +++ b/FEXCore/Source/Interface/Core/OpcodeDispatcher/Vector.cpp @@ -598,14 +598,14 @@ Ref OpDispatchBuilder::InsertScalarFCMPOpImpl(OpSize Size, IR::OpSize OpDstSize, } void OpDispatchBuilder::InsertScalarFCMPOp(OpcodeArgs, IR::OpSize ElementSize) { - const uint8_t CompType = Op->Src[1].Literal(); + const uint8_t CompType = Op->Src[1].Literal() & 0b111; const auto DstSize = GetGuestVectorLength(); const auto SrcSize = OpSizeFromSrc(Op); Ref Src1 = LoadSourceFPR_WithOpSize(Op, Op->Dest, DstSize, Op->Flags); Ref Src2 = LoadSourceFPR_WithOpSize(Op, Op->Src[0], SrcSize, Op->Flags, {.AllowUpperGarbage = true}); - Ref Result = InsertScalarFCMPOpImpl(DstSize, OpSizeFromDst(Op), ElementSize, Src1, Src2, CompType & 0b111, false); + Ref Result = InsertScalarFCMPOpImpl(DstSize, OpSizeFromDst(Op), ElementSize, Src1, Src2, CompType, false); // ARM doesn't have any instructions that handle the semantics of NLT and NLE directly. // In fact, these are the two SSE compatison types where we cannot use VFCMPScalarInsert @@ -623,7 +623,7 @@ void OpDispatchBuilder::InsertScalarFCMPOp(OpcodeArgs, IR::OpSize ElementSize) { } void OpDispatchBuilder::AVXInsertScalarFCMPOp(OpcodeArgs, IR::OpSize ElementSize) { - const uint8_t CompType = Op->Src[2].Literal(); + const uint8_t CompType = Op->Src[2].Literal() & 0b11111; const auto DstSize = GetGuestVectorLength(); const auto SrcSize = OpSizeFromSrc(Op); @@ -633,7 +633,7 @@ void OpDispatchBuilder::AVXInsertScalarFCMPOp(OpcodeArgs, IR::OpSize ElementSize Ref Src1 = LoadSourceFPR_WithOpSize(Op, Op->Src[0], DstSize, Op->Flags); Ref Src2 = LoadSourceFPR_WithOpSize(Op, Op->Src[1], SrcSize, Op->Flags, {.AllowUpperGarbage = true}); - Ref Result = InsertScalarFCMPOpImpl(DstSize, OpSizeFromDst(Op), ElementSize, Src1, Src2, CompType & 0b11111, true); + Ref Result = InsertScalarFCMPOpImpl(DstSize, OpSizeFromDst(Op), ElementSize, Src1, Src2, CompType, true); StoreResultFPR_WithOpSize(Op, Op->Dest, Result, DstSize); }