shader: Avoid CPU side undefined behavior on I2F

This commit is contained in:
ReinUsesLisp 2021-06-02 03:10:15 -03:00 committed by ameerj
parent 79f2fe1a39
commit 4f8b68fb04
1 changed files with 2 additions and 0 deletions

View File

@ -114,6 +114,8 @@ void I2F(TranslatorVisitor& v, u64 insn, IR::U32U64 src) {
IR::U1 is_least; IR::U1 is_least;
if (src_bitsize == 64) { if (src_bitsize == 64) {
is_least = v.ir.IEqual(src, v.ir.Imm64(std::numeric_limits<s64>::min())); is_least = v.ir.IEqual(src, v.ir.Imm64(std::numeric_limits<s64>::min()));
} else if (src_bitsize == 32) {
is_least = v.ir.IEqual(src, v.ir.Imm32(std::numeric_limits<s32>::min()));
} else { } else {
const IR::U32 least_value{v.ir.Imm32(-(1 << (src_bitsize - 1)))}; const IR::U32 least_value{v.ir.Imm32(-(1 << (src_bitsize - 1)))};
is_least = v.ir.IEqual(src, least_value); is_least = v.ir.IEqual(src, least_value);