mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-01-01 13:29:32 +00:00
Fix issue with native code optimization of TYA+STA.
This would be changed to STY, but that is invalid if the A value is needed afterward. This could affect the code for certain division operations (after the optimizations in commit 4470626ade
).
Here is an example that would be miscompiled:
#pragma optimize -1
#include <stdio.h>
int main(void) {
unsigned i = 55555;
unsigned a,b;
a = b = i / 10000;
printf("%u %u\n", a,b);
}
Also, remove MVN from the list of "ASafe" instructions since it really isn't, although I don't think this was affecting anything in practice.
This commit is contained in:
parent
e71fe5d785
commit
7364e2d2d3
14
Native.pas
14
Native.pas
@ -1561,7 +1561,7 @@ var
|
||||
[m_bcc,m_bcs,m_beq,m_bmi,m_bne,m_bpl,m_bra,m_brl,m_bvs,m_jml,
|
||||
m_jmp_indX,m_jsl,m_lda_abs,m_lda_absx,m_lda_dir,m_lda_dirx,
|
||||
m_lda_imm,m_lda_indl,m_lda_indly,m_lda_long,m_lda_longx,m_lda_s,
|
||||
m_mvn,m_pla,m_rtl,m_rts,m_tdc,m_txa,m_tya,m_tsc,d_end,d_bmov,
|
||||
m_pla,m_rtl,m_rts,m_tdc,m_txa,m_tya,m_tsc,d_end,d_bmov,
|
||||
d_add,d_pin,d_wrd,d_sym,d_cns] then begin
|
||||
ASafe := true;
|
||||
goto 1;
|
||||
@ -1890,12 +1890,16 @@ var
|
||||
|
||||
m_tya:
|
||||
if npeep[ns+1].opcode = m_sta_dir then begin
|
||||
npeep[ns+1].opcode := m_sty_dir;
|
||||
Remove(ns);
|
||||
if ASafe(ns+2) then begin
|
||||
npeep[ns+1].opcode := m_sty_dir;
|
||||
Remove(ns);
|
||||
end; {if}
|
||||
end {if}
|
||||
else if npeep[ns+1].opcode = m_sta_abs then begin
|
||||
npeep[ns+1].opcode := m_sty_abs;
|
||||
Remove(ns);
|
||||
if ASafe(ns+2) then begin
|
||||
npeep[ns+1].opcode := m_sty_abs;
|
||||
Remove(ns);
|
||||
end; {if}
|
||||
end; {else if}
|
||||
|
||||
m_tyx:
|
||||
|
2
cc.notes
2
cc.notes
@ -2051,6 +2051,8 @@ int foo(int[42]);
|
||||
|
||||
226. The unary + operator should apply the integer promotions to its operand, e.g. promoting char to int. This can affect the value of sizeof(+expression).
|
||||
|
||||
227. If an unsigned 16-bit value was divided by a constant 1000 or larger, and the result was assigned to two different variables (e.g. a = b = c/1000), incorrect code would be generated when using native code peephole optimization. (This was a regression introduced in ORCA/C 2.2.0 B6.)
|
||||
|
||||
-- Bugs from C 2.1.0 that have been fixed -----------------------------------
|
||||
|
||||
1. In some situations, fread() reread the first 1K or so of the file.
|
||||
|
Loading…
Reference in New Issue
Block a user