Browse Source

+ always do the x86_64 reference optimizations as if SS=DS, because the CPU
basically ignores these segments in long mode

git-svn-id: trunk@37515 -

nickysn 7 years ago
parent
commit
5ae32a0ec5
1 changed files with 14 additions and 0 deletions
  1. 14 0
      compiler/x86/aasmcpu.pas

+ 14 - 0
compiler/x86/aasmcpu.pas

@@ -1873,10 +1873,24 @@ implementation
       var
       var
         ss_equals_ds: boolean;
         ss_equals_ds: boolean;
       begin
       begin
+{$ifdef x86_64}
+        { x86_64 in long mode ignores all segment base, limit and access rights
+          checks for the DS, ES and SS registers, so we can set ss_equals_ds to
+          true (and thus, perform stronger optimizations on the reference),
+          regardless of whether this is inline asm or not (so, even if the user
+          is doing tricks by loading different values into DS and SS, it still
+          doesn't matter while the processor is in long mode) }
+        ss_equals_ds:=True;
+{$else x86_64}
+        { for i8086 and i386 inline asm, we assume SS<>DS, even if we're
+          compiling for a memory model, where SS=DS, because the user might be
+          doing something tricky with the segment registers (and may have
+          temporarily set them differently) }
         if inlineasm then
         if inlineasm then
           ss_equals_ds:=False
           ss_equals_ds:=False
         else
         else
           ss_equals_ds:=segment_regs_equal(NR_DS,NR_SS);
           ss_equals_ds:=segment_regs_equal(NR_DS,NR_SS);
+{$endif x86_64}
         { remove redundant segment overrides }
         { remove redundant segment overrides }
         if (ref.segment<>NR_NO) and
         if (ref.segment<>NR_NO) and
            ((inlineasm and (ref.segment=get_default_segment_of_ref(ref))) or
            ((inlineasm and (ref.segment=get_default_segment_of_ref(ref))) or