Fix bug where 32-bit addition and subtraction results are not saved in some cases.

This could happen in certain cases where the destination is not considered "simple" (e.g. because it is a local array location that does not fit in the direct page).

The following program demonstrates the problem:

#pragma optimize 1
int main(void) {
    long temp1 = 1, temp2 = 2, A[64];
    long B[2] = {0};
    B[1] = temp1 + temp2;
    return B[1]; /* should return 3 */
}
This commit is contained in:
Stephen Heumann 2017-07-13 23:39:51 -05:00
parent afe3e9586b
commit ad31ecfcae

View File

@ -609,7 +609,7 @@ else begin
DoOp(0, m_sta_abs, m_sta_dir, save, 2); DoOp(0, m_sta_abs, m_sta_dir, save, 2);
end; {else} end; {else}
end {if} end {if}
else if Simple(op^.right) then begin else if (save = nil) and Simple(op^.right) then begin
gLong.preference := gLong.preference & A_X; gLong.preference := gLong.preference & A_X;
GenTree(op^.left); GenTree(op^.left);
GenImplied(clc); GenImplied(clc);