mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-12-10 05:38:49 +00:00
constant_propagation_pass: Handle a few more bitwise instructions. (#3482)
Co-authored-by: TheTurtle <47210458+raphaelthegreat@users.noreply.github.com>
This commit is contained in:
@@ -456,6 +456,24 @@ void ConstantPropagation(IR::Block& block, IR::Inst& inst) {
|
|||||||
case IR::Opcode::BitwiseXor32:
|
case IR::Opcode::BitwiseXor32:
|
||||||
FoldWhenAllImmediates(inst, [](u32 a, u32 b) { return a ^ b; });
|
FoldWhenAllImmediates(inst, [](u32 a, u32 b) { return a ^ b; });
|
||||||
return;
|
return;
|
||||||
|
case IR::Opcode::BitwiseNot32:
|
||||||
|
FoldWhenAllImmediates(inst, [](u32 a) { return ~a; });
|
||||||
|
return;
|
||||||
|
case IR::Opcode::BitReverse32:
|
||||||
|
FoldWhenAllImmediates(inst, [](u32 a) {
|
||||||
|
u32 res{};
|
||||||
|
for (s32 i = 0; i < 32; i++, a >>= 1) {
|
||||||
|
res = (res << 1) | (a & 1);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
case IR::Opcode::BitCount32:
|
||||||
|
FoldWhenAllImmediates(inst, [](u32 a) { return static_cast<u32>(std::popcount(a)); });
|
||||||
|
return;
|
||||||
|
case IR::Opcode::BitCount64:
|
||||||
|
FoldWhenAllImmediates(inst, [](u64 a) { return static_cast<u32>(std::popcount(a)); });
|
||||||
|
return;
|
||||||
case IR::Opcode::BitFieldUExtract:
|
case IR::Opcode::BitFieldUExtract:
|
||||||
FoldWhenAllImmediates(inst, [](u32 base, u32 shift, u32 count) {
|
FoldWhenAllImmediates(inst, [](u32 base, u32 shift, u32 count) {
|
||||||
if (static_cast<size_t>(shift) + static_cast<size_t>(count) > 32) {
|
if (static_cast<size_t>(shift) + static_cast<size_t>(count) > 32) {
|
||||||
|
|||||||
Reference in New Issue
Block a user