Skip to content

Bug fix to new ADD/SUB optimisation where conditions are concerned

Summary

This patch fixes a bug where the new PostPeepholeOptADDSUB optimisation over at !86 (merged) didn't accommodate for the carry flag inverting in any follow-up conditional instructions, which usually occurred when the project was built under -CriotR rules (in other situations, there tend to be CMP instruction in between).

However, the overflow and range checks introduced by -CriotR did not track the FLAGS registers properly, which this merge request now fixes so the peephole optimisation behaves properly.

Finally, two new overflow tests, one with -OoNOPEEPHOLE and one without, test the overflow and range error rules, including edge cases where the result is zero.

System

  • Processor architecture: i8086, i386, x86_64, possibly others because of the introduction of FLAGS tracking in platform-agnostic code.

What is the current bug behavior?

Overflow errors trigger when they shouldn't whenever 128 is added or subtracted from an integer.

What is the behavior after applying this patch?

False overflow errors should no longer trigger.

Merge request reports