mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-11-16 03:00:47 +01:00
translate: Restore simplier ADDC implementation (#5200)
This commit is contained in:
1 parent
2338a06f92
commit
d1cb90dbbe
3 files changed
+14
-21
No files matched your search
@@ -292,14 +292,12 @@ void Translator::S_ADDC_U32(const GcnInst& inst) {
|
||||
const IR::U32 src0{GetSrc(inst.src[0])};
|
||||
const IR::U32 src1{GetSrc(inst.src[1])};
|
||||
const IR::U32 carry{ir.Select(ir.GetScc(), ir.Imm32(1U), ir.Imm32(0U))};
|
||||
const IR::Value tmp1{ir.IAddCarry(src0, src1)};
|
||||
const IR::U32 result1{ir.CompositeExtract(tmp1, 0)};
|
||||
const IR::U32 carry_out1{ir.CompositeExtract(tmp1, 1)};
|
||||
const IR::Value tmp2{ir.IAddCarry(result1, carry)};
|
||||
const IR::U32 result2{ir.CompositeExtract(tmp2, 0)};
|
||||
const IR::U32 carry_out2{ir.CompositeExtract(tmp2, 1)};
|
||||
const IR::U32 result1{ir.IAdd(src0, src1)};
|
||||
const IR::U32 result2{ir.IAdd(result1, carry)};
|
||||
const IR::U1 carry_out1{ir.ILessThan(result1, src0, false)};
|
||||
const IR::U1 carry_out2{ir.ILessThan(result2, result1, false)};
|
||||
SetDst(inst.dst[0], result2);
|
||||
ir.SetScc(ir.INotEqual(ir.BitwiseOr(carry_out1, carry_out2), ir.Imm32(0)));
|
||||
ir.SetScc(ir.LogicalOr(carry_out1, carry_out2));
|
||||
}
|
||||
|
||||
void Translator::S_MIN_U32(bool is_signed, const GcnInst& inst) {
|
||||
|
||||
@@ -786,19 +786,16 @@ void Translator::V_SUBREV_I32(const GcnInst& inst) {
|
||||
}
|
||||
|
||||
void Translator::V_ADDC_U32(const GcnInst& inst) {
|
||||
// Unsigned components
|
||||
const IR::U32 src0{GetSrc(inst.src[0])};
|
||||
const IR::U32 src1{GetSrc(inst.src[1])};
|
||||
const IR::U32 carry{GetCarryIn(inst)};
|
||||
const IR::Value tmp1{ir.IAddCarry(src0, src1)};
|
||||
const IR::U32 result1{ir.CompositeExtract(tmp1, 0)};
|
||||
const IR::U32 carry_out1{ir.CompositeExtract(tmp1, 1)};
|
||||
const IR::Value tmp2{ir.IAddCarry(result1, carry)};
|
||||
const IR::U32 result2{ir.CompositeExtract(tmp2, 0)};
|
||||
const IR::U32 carry_out2{ir.CompositeExtract(tmp2, 1)};
|
||||
const IR::U32 result1{ir.IAdd(src0, src1)};
|
||||
const IR::U32 result2{ir.IAdd(result1, carry)};
|
||||
const IR::U1 carry_out1{ir.ILessThan(result1, src0, false)};
|
||||
const IR::U1 carry_out2{ir.ILessThan(result2, result1, false)};
|
||||
SetDst(inst.dst[0], result2);
|
||||
|
||||
const IR::U1 did_overflow{ir.INotEqual(ir.BitwiseOr(carry_out1, carry_out2), ir.Imm32(0))};
|
||||
const IR::U1 did_overflow{ir.LogicalOr(carry_out1, carry_out2)};
|
||||
SetCarryOut(inst, did_overflow);
|
||||
}
|
||||
|
||||
|
||||
@@ -683,12 +683,10 @@ static bool IsReadConstSource(const IR::Value base) {
|
||||
|
||||
void SimplifyReadConstAddressAdd(IR::Inst& inst) {
|
||||
// This handles the following pattern by combining the addition with the offset
|
||||
// %82 = IAdd32 %65, #28816
|
||||
// %83 = ULessThan32 %82, %65
|
||||
// %84 = SelectU32 %83, #1, #0
|
||||
// %85 = IAdd32 %66, %84
|
||||
// %86 = CompositeConstructU32x2 %82, %85
|
||||
// %87 = ReadConst (flags=0x0) %86, #0
|
||||
// s_add_u32 s12, s2, <offset>
|
||||
// s_addc_u32 s13, s3, 0
|
||||
// s_load_dword s16, s[12:13], 0x0
|
||||
|
||||
if (inst.GetOpcode() != IR::Opcode::ReadConst) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user