emit_x64_vector: -0x80000000 isn't -0x80000000
This commit is contained in:
parent
b455b566e7
commit
8f4c1a8558
3 changed files with 15 additions and 3 deletions
|
@ -2252,7 +2252,7 @@ void EmitX64::EmitVectorSignedSaturatedNarrowToSigned64(EmitContext& ctx, IR::In
|
||||||
EmitOneArgumentFallbackWithSaturation(code, ctx, inst, [](VectorArray<s32>& result, const VectorArray<s64>& a) {
|
EmitOneArgumentFallbackWithSaturation(code, ctx, inst, [](VectorArray<s32>& result, const VectorArray<s64>& a) {
|
||||||
bool qc_flag = false;
|
bool qc_flag = false;
|
||||||
for (size_t i = 0; i < a.size(); ++i) {
|
for (size_t i = 0; i < a.size(); ++i) {
|
||||||
const s64 saturated = std::clamp<s64>(a[i], -0x80000000, 0x7FFFFFFF);
|
const s64 saturated = std::clamp<s64>(a[i], -s64(0x80000000), s64(0x7FFFFFFF));
|
||||||
result[i] = static_cast<s32>(saturated);
|
result[i] = static_cast<s32>(saturated);
|
||||||
qc_flag |= saturated != a[i];
|
qc_flag |= saturated != a[i];
|
||||||
}
|
}
|
||||||
|
|
|
@ -798,8 +798,8 @@ INST(SHL_2, "SHL", "0Q001
|
||||||
//INST(SQSHL_imm_2, "SQSHL (immediate)", "0Q0011110IIIIiii011101nnnnnddddd")
|
//INST(SQSHL_imm_2, "SQSHL (immediate)", "0Q0011110IIIIiii011101nnnnnddddd")
|
||||||
INST(SHRN, "SHRN, SHRN2", "0Q0011110IIIIiii100001nnnnnddddd")
|
INST(SHRN, "SHRN, SHRN2", "0Q0011110IIIIiii100001nnnnnddddd")
|
||||||
INST(RSHRN, "RSHRN, RSHRN2", "0Q0011110IIIIiii100011nnnnnddddd")
|
INST(RSHRN, "RSHRN, RSHRN2", "0Q0011110IIIIiii100011nnnnnddddd")
|
||||||
//INST(SQSHRN_2, "SQSHRN, SQSHRN2", "0Q0011110IIIIiii100101nnnnnddddd")
|
INST(SQSHRN_2, "SQSHRN, SQSHRN2", "0Q0011110IIIIiii100101nnnnnddddd")
|
||||||
//INST(SQRSHRN_2, "SQRSHRN, SQRSHRN2", "0Q0011110IIIIiii100111nnnnnddddd")
|
INST(SQRSHRN_2, "SQRSHRN, SQRSHRN2", "0Q0011110IIIIiii100111nnnnnddddd")
|
||||||
INST(SSHLL, "SSHLL, SSHLL2", "0Q0011110IIIIiii101001nnnnnddddd")
|
INST(SSHLL, "SSHLL, SSHLL2", "0Q0011110IIIIiii101001nnnnnddddd")
|
||||||
//INST(SCVTF_fix_2, "SCVTF (vector, fixed-point)", "0Q0011110IIIIiii111001nnnnnddddd")
|
//INST(SCVTF_fix_2, "SCVTF (vector, fixed-point)", "0Q0011110IIIIiii111001nnnnnddddd")
|
||||||
//INST(FCVTZS_fix_2, "FCVTZS (vector, fixed-point)", "0Q0011110IIIIiii111111nnnnnddddd")
|
//INST(FCVTZS_fix_2, "FCVTZS (vector, fixed-point)", "0Q0011110IIIIiii111111nnnnnddddd")
|
||||||
|
|
|
@ -27,6 +27,7 @@ enum class Signedness {
|
||||||
enum class Narrowing {
|
enum class Narrowing {
|
||||||
Truncation,
|
Truncation,
|
||||||
SaturateToUnsigned,
|
SaturateToUnsigned,
|
||||||
|
SaturateToSigned,
|
||||||
};
|
};
|
||||||
|
|
||||||
IR::U128 PerformRoundingCorrection(TranslatorVisitor& v, size_t esize, u64 round_value, IR::U128 original, IR::U128 shifted) {
|
IR::U128 PerformRoundingCorrection(TranslatorVisitor& v, size_t esize, u64 round_value, IR::U128 original, IR::U128 shifted) {
|
||||||
|
@ -110,6 +111,9 @@ bool ShiftRightNarrowing(TranslatorVisitor& v, bool Q, Imm<4> immh, Imm<3> immb,
|
||||||
case Narrowing::SaturateToUnsigned:
|
case Narrowing::SaturateToUnsigned:
|
||||||
ASSERT(signedness == Signedness::Signed);
|
ASSERT(signedness == Signedness::Signed);
|
||||||
return v.ir.VectorSignedSaturatedNarrowToUnsigned(source_esize, wide_result);
|
return v.ir.VectorSignedSaturatedNarrowToUnsigned(source_esize, wide_result);
|
||||||
|
case Narrowing::SaturateToSigned:
|
||||||
|
ASSERT(signedness == Signedness::Signed);
|
||||||
|
return v.ir.VectorSignedSaturatedNarrowToSigned(source_esize, wide_result);
|
||||||
}
|
}
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
return IR::U128{};
|
return IR::U128{};
|
||||||
|
@ -192,6 +196,14 @@ bool TranslatorVisitor::RSHRN(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd)
|
||||||
return ShiftRightNarrowing(*this, Q, immh, immb, Vn, Vd, Rounding::Round, Narrowing::Truncation, Signedness::Unsigned);
|
return ShiftRightNarrowing(*this, Q, immh, immb, Vn, Vd, Rounding::Round, Narrowing::Truncation, Signedness::Unsigned);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TranslatorVisitor::SQSHRN_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) {
|
||||||
|
return ShiftRightNarrowing(*this, Q, immh, immb, Vn, Vd, Rounding::None, Narrowing::SaturateToSigned, Signedness::Signed);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TranslatorVisitor::SQRSHRN_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) {
|
||||||
|
return ShiftRightNarrowing(*this, Q, immh, immb, Vn, Vd, Rounding::Round, Narrowing::SaturateToSigned, Signedness::Signed);
|
||||||
|
}
|
||||||
|
|
||||||
bool TranslatorVisitor::SQSHRUN_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) {
|
bool TranslatorVisitor::SQSHRUN_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) {
|
||||||
return ShiftRightNarrowing(*this, Q, immh, immb, Vn, Vd, Rounding::None, Narrowing::SaturateToUnsigned, Signedness::Signed);
|
return ShiftRightNarrowing(*this, Q, immh, immb, Vn, Vd, Rounding::None, Narrowing::SaturateToUnsigned, Signedness::Signed);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue