constant_propagation_pass: Shift with non-zero value does not require c flag as input

This commit is contained in:
Merry 2022-07-23 18:42:43 +01:00 committed by merry
parent 5a864f41c6
commit 9bdff6a9aa

View file

@ -300,6 +300,7 @@ bool FoldShifts(IR::Inst& inst) {
} }
const auto shift_amount = inst.GetArg(1); const auto shift_amount = inst.GetArg(1);
if (shift_amount.IsZero()) { if (shift_amount.IsZero()) {
if (carry_inst) { if (carry_inst) {
carry_inst->ReplaceUsesWith(inst.GetArg(2)); carry_inst->ReplaceUsesWith(inst.GetArg(2));
@ -308,6 +309,10 @@ bool FoldShifts(IR::Inst& inst) {
return false; return false;
} }
if (inst.NumArgs() == 3 && shift_amount.IsImmediate() && !shift_amount.IsZero()) {
inst.SetArg(2, IR::Value(false));
}
if (!inst.AreAllArgsImmediates() || carry_inst) { if (!inst.AreAllArgsImmediates() || carry_inst) {
return false; return false;
} }