浏览代码

* avoid assembler errors for the MovOpMov2MovOp optimziation in case the size of the instruction
gets changed and the first one contains a constant, resolves #34933

git-svn-id: trunk@41021 -

florian 6 年之前
父节点
当前提交
cfd0790f89
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      compiler/x86/aoptx86.pas

+ 4 - 0
compiler/x86/aoptx86.pas

@@ -1879,6 +1879,10 @@ unit aoptx86;
                           debug_op2str(taicpu(p).opcode)+debug_opsize2str(taicpu(p).opsize)+' '+
                           debug_op2str(taicpu(hp1).opcode)+debug_opsize2str(taicpu(hp1).opsize)+' '+
                           debug_op2str(taicpu(hp2).opcode)+debug_opsize2str(taicpu(hp2).opsize),p);
+                    { limit size of constants as well to avoid assembler errors, but
+                      check opsize to avoid overflow when left shifting the 1 }
+                    if (taicpu(p).oper[0]^.typ=top_const) and (topsize2memsize[taicpu(hp2).opsize]<=4) then
+                      taicpu(p).oper[0]^.val:=taicpu(p).oper[0]^.val and ((qword(1) shl (topsize2memsize[taicpu(hp2).opsize]*8))-1);
                     taicpu(hp1).changeopsize(taicpu(hp2).opsize);
                     taicpu(p).changeopsize(taicpu(hp2).opsize);
                     if taicpu(p).oper[0]^.typ=top_reg then