* do not generate lea with 16 bit references on x86-64, resolves #40936

This commit is contained in:
florian 2024-10-07 22:53:54 +02:00
parent 28e1daa8e1
commit e91c8040ea
2 changed files with 17 additions and 7 deletions

View File

@ -23,7 +23,7 @@ unit aoptx86;
{$i fpcdefs.inc}
{ $define DEBUG_AOPTCPU}
{$define DEBUG_AOPTCPU}
{$ifdef EXTDEBUG}
{$define DEBUG_AOPTCPU}
@ -12071,8 +12071,8 @@ unit aoptx86;
end;
A_ADD:
begin
if (taicpu(next).opsize = S_B) or
{ LEA doesn't support 8-bit operands }
if { LEA doesn't support 8-bit in general and 16-bit on x86-64 operands }
(taicpu(next).opsize in [S_B{$ifdef x86_64},S_W{$endif x86_64}]) or
(taicpu(next).oper[1]^.typ <> top_reg) or
{ Must write to a register }
(taicpu(next).oper[0]^.typ = top_ref) then
@ -12083,8 +12083,8 @@ unit aoptx86;
end;
A_SUB:
begin
if (taicpu(next).opsize = S_B) or
{ LEA doesn't support 8-bit operands }
if { LEA doesn't support 8-bit in general and 16-bit on x86-64 operands }
(taicpu(next).opsize in [S_B{$ifdef x86_64},S_W{$endif x86_64}]) or
(taicpu(next).oper[1]^.typ <> top_reg) or
{ Must write to a register }
(taicpu(next).oper[0]^.typ <> top_const) or
@ -12099,8 +12099,8 @@ unit aoptx86;
A_SAL,
A_SHL:
begin
if (taicpu(next).opsize = S_B) or
{ LEA doesn't support 8-bit operands }
if { LEA doesn't support 8-bit in general and 16-bit on x86-64 operands }
(taicpu(next).opsize in [S_B{$ifdef x86_64},S_W{$endif x86_64}]) or
(taicpu(next).oper[1]^.typ <> top_reg) or
{ Must write to a register }
(taicpu(next).oper[0]^.typ <> top_const) or

10
tests/webtbs/tw40936.pp Normal file
View File

@ -0,0 +1,10 @@
{ %norun }
var
b: boolean;
w: word;
begin
b := (w shr 1) <> 0;
w := w shl 1; // project1.lpr(7,3) Error: Asm: 16 or 32 bit references not supported
if b then w := w xor 1;
end.