* x86: Fixed bug in TEST/JNE/TEST/JNE optimisation that caused bad code to be generated under -O3

This commit is contained in:
J. Gareth "Curious Kit" Moreton 2023-07-27 18:54:59 +01:00 committed by J. Gareth "Kit" Moreton
parent 11957d9a60
commit 699db16fe4

View File

@ -5313,7 +5313,6 @@ unit aoptx86;
{ Search for:
test $x,(reg/ref)
jne @lbl1
...
test $y,(reg/ref) (same register or reference)
jne @lbl1
@ -5481,6 +5480,16 @@ unit aoptx86;
(FirstValue = -1) or
(SecondValue = -1) or
MatchOperand(taicpu(hp1_dist).oper[0]^, taicpu(hp1).oper[0]^)
) and
(
{ In this situation, the TEST/JNE pairs must be adjacent (fixes #40366) }
{ Always adjacent under -O2 and under }
not(cs_opt_level3 in current_settings.optimizerswitches) or
(
GetNextInstruction(hp1, hp1_last) and
(hp1_last = p_dist)
)
) then
begin
{ Same jump location... can be a register since nothing's changed }