constant_propagation_pass: Don't fold add if we nee flags

Results in incorrect flags
This commit is contained in:
MerryMage 2020-04-29 15:33:12 +01:00
parent e7166e8ba7
commit 24229ab899
3 changed files with 91 additions and 1 deletions

View file

@ -86,6 +86,10 @@ void FoldAdd(IR::Inst& inst, bool is_32_bit) {
return;
}
if (inst.HasAssociatedPseudoOperation()) {
return;
}
if (!lhs.IsImmediate() && rhs.IsImmediate()) {
const IR::Inst* lhs_inst = lhs.GetInstRecursive();
if (lhs_inst->GetOpcode() == inst.GetOpcode() && lhs_inst->GetArg(1).IsImmediate() && lhs_inst->GetArg(2).IsImmediate()) {
@ -96,7 +100,7 @@ void FoldAdd(IR::Inst& inst, bool is_32_bit) {
}
}
if (inst.AreAllArgsImmediates() && !inst.HasAssociatedPseudoOperation()) {
if (inst.AreAllArgsImmediates()) {
const u64 result = lhs.GetImmediateAsU64() + rhs.GetImmediateAsU64() + carry.GetU1();
ReplaceUsesWith(inst, is_32_bit, result);
return;