re PR target/39942 (Nonoptimal code - leaveq; xchg %ax,%ax; retq)
authorH.J. Lu <hongjiu.lu@intel.com>
Mon, 18 May 2009 17:21:13 +0000 (17:21 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Mon, 18 May 2009 17:21:13 +0000 (10:21 -0700)
2009-05-18  H.J. Lu  <hongjiu.lu@intel.com>

PR target/39942
* config/i386/i386.c (ix86_avoid_jump_misspredicts): Replace
gen_align with gen_pad.
(ix86_reorg): Check ASM_OUTPUT_MAX_SKIP_PAD instead of
#ifdef ASM_OUTPUT_MAX_SKIP_ALIGN.

* config/i386/i386.h (ASM_OUTPUT_MAX_SKIP_PAD): New.
* config/i386/x86-64.h (ASM_OUTPUT_MAX_SKIP_PAD): Likewise.

* config/i386/i386.md (align): Renamed to ...
(pad): This.  Replace ASM_OUTPUT_MAX_SKIP_ALIGN with
ASM_OUTPUT_MAX_SKIP_PAD.

From-SVN: r147671

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/config/i386/i386.h
gcc/config/i386/i386.md
gcc/config/i386/x86-64.h

index 68b34198c90b998e77138cd11c77fc4171d10acc..8260f928946f50e896211d6c359052a539360b7f 100644 (file)
@@ -1,3 +1,18 @@
+2009-05-18  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR target/39942
+       * config/i386/i386.c (ix86_avoid_jump_misspredicts): Replace
+       gen_align with gen_pad.
+       (ix86_reorg): Check ASM_OUTPUT_MAX_SKIP_PAD instead of
+       #ifdef ASM_OUTPUT_MAX_SKIP_ALIGN.
+
+       * config/i386/i386.h (ASM_OUTPUT_MAX_SKIP_PAD): New.
+       * config/i386/x86-64.h (ASM_OUTPUT_MAX_SKIP_PAD): Likewise.
+
+       * config/i386/i386.md (align): Renamed to ...
+       (pad): This.  Replace ASM_OUTPUT_MAX_SKIP_ALIGN with
+       ASM_OUTPUT_MAX_SKIP_PAD.
+
 2009-05-18  Andreas Schwab  <schwab@linux-m68k.org>
 
        * config.gcc: Fix variable syntax.
index acd3069c7fc8e9f24e6efdd91360e2af54922a30..e9f8b9566a081db1337fc5108bf3e9755e7d4bb9 100644 (file)
@@ -27334,7 +27334,7 @@ ix86_avoid_jump_mispredicts (void)
          if (dump_file)
            fprintf (dump_file, "Padding insn %i by %i bytes!\n",
                     INSN_UID (insn), padsize);
-          emit_insn_before (gen_align (GEN_INT (padsize)), insn);
+          emit_insn_before (gen_pad (GEN_INT (padsize)), insn);
        }
     }
 }
@@ -27402,7 +27402,7 @@ ix86_reorg (void)
     {
       if (TARGET_PAD_RETURNS)
        ix86_pad_returns ();
-#ifdef ASM_OUTPUT_MAX_SKIP_ALIGN
+#ifdef ASM_OUTPUT_MAX_SKIP_PAD
       if (TARGET_FOUR_JUMP_LIMIT)
        ix86_avoid_jump_mispredicts ();
 #endif
index f41ed7db665c242a1b6e708cac2b500a15e40208..e42686b480928d51c54a9f552bd6c0725718c017 100644 (file)
@@ -2175,6 +2175,22 @@ do {                                                                     \
 #define ASM_OUTPUT_OPCODE(STREAM, PTR) \
   ASM_OUTPUT_AVX_PREFIX ((STREAM), (PTR))
 
+/* A C statement to output to the stdio stream FILE an assembler
+   command to pad the location counter to a multiple of 1<<LOG
+   bytes if it is within MAX_SKIP bytes.  */
+
+#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
+#undef  ASM_OUTPUT_MAX_SKIP_PAD
+#define ASM_OUTPUT_MAX_SKIP_PAD(FILE, LOG, MAX_SKIP)                   \
+  if ((LOG) != 0)                                                      \
+    {                                                                  \
+      if ((MAX_SKIP) == 0)                                             \
+        fprintf ((FILE), "\t.p2align %d\n", (LOG));                    \
+      else                                                             \
+        fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP));    \
+    }
+#endif
+
 /* Under some conditions we need jump tables in the text section,
    because the assembler cannot handle label differences between
    sections.  This is the case for x86_64 on Mach-O for example.  */
index 198b59d2e4769910af6688f24449fabb15e55e9b..2e2880220b8efd7c45298ca4badfc826d69c6ecc 100644 (file)
    (set_attr "length_immediate" "0")
    (set_attr "modrm" "0")])
 
-;; Align to 16-byte boundary, max skip in op0.  Used to avoid
+;; Pad to 16-byte boundary, max skip in op0.  Used to avoid
 ;; branch prediction penalty for the third jump in a 16-byte
 ;; block on K8.
 
-(define_insn "align"
+(define_insn "pad"
   [(unspec_volatile [(match_operand 0 "" "")] UNSPECV_ALIGN)]
   ""
 {
-#ifdef ASM_OUTPUT_MAX_SKIP_ALIGN
-  ASM_OUTPUT_MAX_SKIP_ALIGN (asm_out_file, 4, (int)INTVAL (operands[0]));
+#ifdef ASM_OUTPUT_MAX_SKIP_PAD
+  ASM_OUTPUT_MAX_SKIP_PAD (asm_out_file, 4, (int)INTVAL (operands[0]));
 #else
   /* It is tempting to use ASM_OUTPUT_ALIGN here, but we don't want to do that.
      The align insn is used to avoid 3 jump instructions in the row to improve
index 96649af7d0e8dd79215e1fe0e4cead11c2322114..5d6958cc4adee4e5d563cf29ae233119968f5d6c 100644 (file)
@@ -81,6 +81,15 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
       }                                                                        \
     }                                                                  \
   } while (0)
+#undef  ASM_OUTPUT_MAX_SKIP_PAD
+#define ASM_OUTPUT_MAX_SKIP_PAD(FILE, LOG, MAX_SKIP)                   \
+  if ((LOG) != 0)                                                      \
+    {                                                                  \
+      if ((MAX_SKIP) == 0)                                             \
+        fprintf ((FILE), "\t.p2align %d\n", (LOG));                    \
+      else                                                             \
+        fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP));    \
+    }
 #endif