diff --git a/src/backend_x64/emit_x64_vector.cpp b/src/backend_x64/emit_x64_vector.cpp index 2291f4bc..0d326c3b 100644 --- a/src/backend_x64/emit_x64_vector.cpp +++ b/src/backend_x64/emit_x64_vector.cpp @@ -5,6 +5,7 @@ */ #include +#include #include "backend_x64/abi.h" #include "backend_x64/block_of_code.h" @@ -604,7 +605,7 @@ void EmitX64::EmitVectorGreaterS64(EmitContext& ctx, IR::Inst* inst) { } EmitTwoArgumentFallback(code, ctx, inst, [](std::array& result, const std::array& a, const std::array& b){ - for (size_t i = 0; i < 2; ++i) { + for (size_t i = 0; i < result.size(); ++i) { result[i] = (a[i] > b[i]) ? ~u64(0) : 0; } }); @@ -975,9 +976,7 @@ void EmitX64::EmitVectorMultiply32(EmitContext& ctx, IR::Inst* inst) { } EmitTwoArgumentFallback(code, ctx, inst, [](std::array& result, const std::array& a, const std::array& b){ - for (size_t i = 0; i < 4; ++i) { - result[i] = a[i] * b[i]; - } + std::transform(a.begin(), a.end(), b.begin(), result.begin(), std::multiplies<>()); }); } @@ -1002,10 +1001,8 @@ void EmitX64::EmitVectorMultiply64(EmitContext& ctx, IR::Inst* inst) { return; } - EmitTwoArgumentFallback(code, ctx, inst, [](std::array& result, const std::array& a, const std::array& b){ - for (size_t i = 0; i < 2; ++i) { - result[i] = a[i] * b[i]; - } + EmitTwoArgumentFallback(code, ctx, inst, [](std::array& result, const std::array& a, const std::array& b) { + std::transform(a.begin(), a.end(), b.begin(), result.begin(), std::multiplies<>()); }); } @@ -1250,9 +1247,9 @@ void EmitX64::EmitVectorPopulationCount(EmitContext& ctx, IR::Inst* inst) { } EmitOneArgumentFallback(code, ctx, inst, [](std::array& result, const std::array& a){ - for (size_t i = 0; i < 16; ++i) { - result[i] = static_cast(Common::BitCount(a[i])); - } + std::transform(a.begin(), a.end(), result.begin(), [](u8 val) { + return static_cast(Common::BitCount(val)); + }); }); } @@ -1377,7 +1374,7 @@ void EmitX64::EmitVectorSignExtend32(EmitContext& ctx, IR::Inst* inst) { } EmitOneArgumentFallback(code, ctx, inst, [](std::array& result, const std::array& a){ - for (size_t i = 0; i < 2; ++i) { + for (size_t i = 0; i < result.size(); ++i) { result[i] = Common::SignExtend<32, u64>(a[i]); } });