Hello,

I updated i386.md part of the patch. Initial patch included handling
of blockage, which is obviously superflous.  Additionally I merged
32-bit and 64-bit peephole2 versions by using mode-specifier W.

ChangeLog

2014-06-12  Kai Tietz  <kti...@redhat.com>

    * config/i386/i386.md (peehole2): To combine
    indirect jump with memory.

2014-06-12  Kai Tietz  <kti...@redhat.com>

    * gcc.target/i386/indjmp-1.c: New test.

Tested for i686-pc-cygwin, and x86_64-unknown-linux-gnu.  Ok for apply?

with addition of adding a second peephole2 pass after sched2 pass, I
was able to get some improvement for PR target/39284.  I think by this
addition we can close bug as fixed.
Additionally additional peephole2 pass shows better results for PR
target/51840 testcase with disabled ASM_GOTO, too.

2014-06-12  Kai Tietz  <kti...@redhat.com>

    PR target/39284
    * passes.def (pass_peephole2): Add second peephole2
    run after sched2 pass.

Tested for i686-pc-cygwin, and x86_64-unknown-linux-gnu.  Ok for apply?

Regards,
Kai

Index: testsuite/gcc.target/i386/indjmp-1.c
===================================================================
--- testsuite/gcc.target/i386/indjmp-1.c    (Revision 0)
+++ testsuite/gcc.target/i386/indjmp-1.c    (Arbeitskopie)
@@ -0,0 +1,23 @@
+/* { dg-do compile  { target ia32 } } */
+/* { dg-options "-O2" } */
+
+#define ADVANCE_AND_DISPATCH() goto *addresses[*pc++]
+
+void
+Interpret(const unsigned char *pc)
+{
+    static const void *const addresses[] = {
+      &&l0, &&l1, &&l2
+    };
+
+l0:
+    ADVANCE_AND_DISPATCH();
+
+l1:
+    ADVANCE_AND_DISPATCH();
+
+l2:
+    return;
+}
+
+/* { dg-final { scan-assembler-not "jmp\[ \t\]*.%eax" } } */
Index: config/i386/i386.md
===================================================================
--- config/i386/i386.md    (Revision 211489)
+++ config/i386/i386.md    (Arbeitskopie)
@@ -11471,6 +11471,15 @@
             (match_dup 3))
           (set (reg:SI SP_REG) (match_dup 4))])])

+;; Combining simple memory jump instruction
+
+(define_peephole2
+  [(set (match_operand:W 0 "register_operand")
+        (match_operand:W 1 "memory_nox32_operand"))
+   (set (pc) (match_dup 0))]
+  "peep2_reg_dead_p (2, operands[0])"
+  [(set (pc) (match_dup 1))])
+
 ;; Call subroutine, returning value in operand 0

 (define_expand "call_value"
Index: passes.def
===================================================================
--- passes.def    (Revision 211489)
+++ passes.def    (Arbeitskopie)
@@ -396,6 +396,7 @@ along with GCC; see the file COPYING3.  If not see
       NEXT_PASS (pass_leaf_regs);
       NEXT_PASS (pass_split_before_sched2);
       NEXT_PASS (pass_sched2);
+      NEXT_PASS (pass_peephole2);
       NEXT_PASS (pass_stack_regs);
       PUSH_INSERT_PASSES_WITHIN (pass_stack_regs)
           NEXT_PASS (pass_split_before_regstack);

Reply via email to