diff --git a/compiler/x86/aoptx86.pas b/compiler/x86/aoptx86.pas index 3971a3c2d6..b2a79adabe 100644 --- a/compiler/x86/aoptx86.pas +++ b/compiler/x86/aoptx86.pas @@ -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 diff --git a/tests/webtbs/tw40936.pp b/tests/webtbs/tw40936.pp new file mode 100644 index 0000000000..2b8024a41f --- /dev/null +++ b/tests/webtbs/tw40936.pp @@ -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.