diff --git a/src/backend_x64/emit_x64_vector_floating_point.cpp b/src/backend_x64/emit_x64_vector_floating_point.cpp index db580a8f..538d5c40 100644 --- a/src/backend_x64/emit_x64_vector_floating_point.cpp +++ b/src/backend_x64/emit_x64_vector_floating_point.cpp @@ -154,11 +154,16 @@ template void ForceToDefaultNaN(BlockOfCode& code, EmitContext& ctx, Xbyak::Xmm result) { if (ctx.FPSCR_DN()) { const Xbyak::Xmm nan_mask = ctx.reg_alloc.ScratchXmm(); - code.movaps(nan_mask, result); - FCODE(cmpordp)(nan_mask, nan_mask); - code.andps(result, nan_mask); - code.andnps(nan_mask, GetNaNVector(code)); - code.orps(result, nan_mask); + if (code.DoesCpuSupport(Xbyak::util::Cpu::tAVX)) { + FCODE(vcmpunordp)(nan_mask, result, result); + FCODE(vblendvp)(result, result, GetNaNVector(code), nan_mask); + } else { + code.movaps(nan_mask, result); + FCODE(cmpordp)(nan_mask, nan_mask); + code.andps(result, nan_mask); + code.andnps(nan_mask, GetNaNVector(code)); + code.orps(result, nan_mask); + } } }