Browse Source

* fixed short/smallint add/sub peephole in case of operations with
only one operand + documented it by example (mantis #11223)


git-svn-id: trunk@10828 -

Jonas Maebe 17 years ago
parent
commit
3b72bf98b0
1 changed files with 31 additions and 3 deletions
  1. 31 3
      compiler/i386/popt386.pas

+ 31 - 3
compiler/i386/popt386.pas

@@ -1276,10 +1276,38 @@ begin
                       {          mov            reg2 reg/ref              }
                       { to       add/sub/or/... reg3/$const, reg/ref      }
                         begin
+                          { by example:
+                              movswl  %si,%eax        movswl  %si,%eax      p
+                              decl    %eax            addl    %edx,%eax     hp1
+                              movw    %ax,%si         movw    %ax,%si       hp2
+                            ->
+                              movswl  %si,%eax        movswl  %si,%eax      p
+                              decw    %eax            addw    %edx,%eax     hp1
+                              movw    %ax,%si         movw    %ax,%si       hp2
+                          }
                           taicpu(hp1).changeopsize(taicpu(hp2).opsize);
-                          taicpu(hp1).loadoper(1,taicpu(hp2).oper[1]^);
-                          if  (taicpu(hp1).oper[0]^.typ = top_reg) then
-                            setsubreg(taicpu(hp1).oper[0]^.reg,getsubreg(taicpu(hp2).oper[0]^.reg));
+                          {
+                            ->
+                              movswl  %si,%eax        movswl  %si,%eax      p
+                              decw    %si             addw    %dx,%si       hp1
+                              movw    %ax,%si         movw    %ax,%si       hp2
+                          }
+                          case taicpu(hp1).ops of
+                            1:
+                             taicpu(hp1).loadoper(0,taicpu(hp2).oper[1]^);
+                            2:
+                              begin
+                                taicpu(hp1).loadoper(1,taicpu(hp2).oper[1]^);
+                                if (taicpu(hp1).oper[0]^.typ = top_reg) then
+                                  setsubreg(taicpu(hp1).oper[0]^.reg,getsubreg(taicpu(hp2).oper[0]^.reg));
+                              end;
+                            else
+                              internalerror(2008042701);
+                          end;
+                          {
+                            ->
+                              decw    %si             addw    %dx,%si       p
+                          }
                           asml.remove(p);
                           asml.remove(hp2);
                           p.free;