* x86: Fixed bug with BT optimisation where operand

sizes bigger than the register word size caused
    incorrect code generation (fixes #40358)
This commit is contained in:
J. Gareth "Curious Kit" Moreton 2023-07-21 03:15:14 +01:00
parent 62bc640306
commit e4d5de8d05

View File

@ -723,10 +723,10 @@ implementation
hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,u32inttype,true);
register_maybe_adjust_setbase(current_asmdata.CurrAsmList,u32inttype,left.location,setbase);
if (tcgsize2size[right.location.size] < 4) or
if (tcgsize2size[right.location.size] < opdef.size) or
(right.location.loc = LOC_CONSTANT) or
{ bt ...,[mem] is slow, see #40039, so try to use a register if we are not optimizing for size }
((right.resultdef.size<=sizeof(aint)) and not(cs_opt_size in current_settings.optimizerswitches)) then
((right.resultdef.size<=u32inttype.size) and not(cs_opt_size in current_settings.optimizerswitches)) then
hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,u32inttype,true);
hreg:=left.location.register;
@ -971,7 +971,7 @@ implementation
if (right.location.loc in [LOC_REGISTER,LOC_CREGISTER]) or
{ bt ...,[mem] is slow, see #40039, so try to use a register if we are not optimizing for size }
((right.resultdef.size<=sizeof(aint)) and not(cs_opt_size in current_settings.optimizerswitches)) then
((right.resultdef.size<=opdef.size) and not(cs_opt_size in current_settings.optimizerswitches)) then
hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,opdef,true);
pleftreg:=left.location.register;