Browse Source

* x86: Fixed bug with BT optimisation where operand
sizes bigger than the register word size caused
incorrect code generation (fixes #40358)

J. Gareth "Curious Kit" Moreton 2 years ago
parent
commit
e4d5de8d05
1 changed files with 3 additions and 3 deletions
  1. 3 3
      compiler/x86/nx86set.pas

+ 3 - 3
compiler/x86/nx86set.pas

@@ -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;