Browse Source

* better rules if a 3 op mul operation is tried

git-svn-id: trunk@45605 -
florian 5 years ago
parent
commit
5f67d830e7
2 changed files with 8 additions and 1 deletions
  1. 1 1
      compiler/x86/cgx86.pas
  2. 7 0
      compiler/x86/nx86add.pas

+ 1 - 1
compiler/x86/cgx86.pas

@@ -2327,7 +2327,7 @@ unit cgx86;
         if (op=OP_MUL) and not (cs_check_overflow in current_settings.localswitches) then
           op:=OP_IMUL;
         case op of
-          OP_NEG,OP_NOT,OP_IMUL:
+          OP_NEG,OP_NOT:
             begin
               inherited a_op_ref_reg(list,op,size,tmpref,reg);
             end;

+ 7 - 0
compiler/x86/nx86add.pas

@@ -1514,6 +1514,13 @@ unit nx86add;
          make no sense if right is a reference }
        if ((left.location.loc<>LOC_REGISTER) and (right.location.loc<>LOC_REGISTER) and
            ((nodetype<>subn) or not(right.location.loc in [LOC_REFERENCE,LOC_CREFERENCE])) and
+           { 3 op mul makes only sense if a constant is involed }
+           ((nodetype<>muln) or (left.location.loc=LOC_CONSTANT) or (right.location.loc=LOC_CONSTANT)
+{$ifndef i8086}
+            or ((CPUX86_HAS_BMI2 in cpu_capabilities[current_settings.cputype]) and (not(needoverflowcheck))
+               )
+{$endif i8086}
+           ) and
            (not(nodetype in [orn,andn,xorn]))) or
          ((nodetype=addn) and (left.location.loc in [LOC_REGISTER,LOC_CREGISTER,LOC_CONSTANT]) and (right.location.loc in [LOC_REGISTER,LOC_CREGISTER,LOC_CONSTANT])) then
          begin