diff mbox

[i386] : Combine memory and indirect jump

Message ID CAEwic4bkmzw1ivAp=pto2gMnbGGRq6x8nwrEoYL6mg6CsQY4XQ@mail.gmail.com
State New
Headers show

Commit Message

Kai Tietz June 20, 2014, 5:52 p.m. UTC
So revert to use a second peephole2 pass before final split before sched2 pass.

Ok for apply
ChangeLog

2014-06-20  Kai Tietz  <ktietz@redhat.com>

    PR target/39284
    * passes.def (peephole2): Add second peephole2 pass before
    split before sched2 pass.
    * config/i386/i386.md (peehole2): To combine
    indirect jump with memory.
    (split2): Likewise.

2014-06-20  Kai Tietz  <ktietz@redhat.com>

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

Tested for i686-pc-cygwin, and x86_64-unknown-linux-gnu running.  Ok
for apply when boostraps are passing?

Regards,
Kai

Comments

Richard Henderson June 20, 2014, 5:55 p.m. UTC | #1
On 06/20/2014 10:52 AM, Kai Tietz wrote:
> 2014-06-20  Kai Tietz  <ktietz@redhat.com>
> 
>     PR target/39284
>     * passes.def (peephole2): Add second peephole2 pass before
>     split before sched2 pass.
>     * config/i386/i386.md (peehole2): To combine
>     indirect jump with memory.
>     (split2): Likewise.

Why are we adding a second pass instead of just moving the one?


r~
Kai Tietz June 20, 2014, 6:07 p.m. UTC | #2
2014-06-20 19:55 GMT+02:00 Richard Henderson <rth@redhat.com>:
> On 06/20/2014 10:52 AM, Kai Tietz wrote:
>> 2014-06-20  Kai Tietz  <ktietz@redhat.com>
>>
>>     PR target/39284
>>     * passes.def (peephole2): Add second peephole2 pass before
>>     split before sched2 pass.
>>     * config/i386/i386.md (peehole2): To combine
>>     indirect jump with memory.
>>     (split2): Likewise.
>
> Why are we adding a second pass instead of just moving the one?
>
>
> r~

I told that in a prior mail in that thread to Jeff. IIRC there are
some conversion of impossible pushes then done too late, additional
some patterns about split & dieing register too.  Means we produce
weaker code.

Kai
Jeff Law June 20, 2014, 6:14 p.m. UTC | #3
On 06/20/14 12:07, Kai Tietz wrote:
> 2014-06-20 19:55 GMT+02:00 Richard Henderson <rth@redhat.com>:
>> On 06/20/2014 10:52 AM, Kai Tietz wrote:
>>> 2014-06-20  Kai Tietz  <ktietz@redhat.com>
>>>
>>>      PR target/39284
>>>      * passes.def (peephole2): Add second peephole2 pass before
>>>      split before sched2 pass.
>>>      * config/i386/i386.md (peehole2): To combine
>>>      indirect jump with memory.
>>>      (split2): Likewise.
>>
>> Why are we adding a second pass instead of just moving the one?
>>
>>
>> r~
>
> I told that in a prior mail in that thread to Jeff. IIRC there are
> some conversion of impossible pushes then done too late, additional
> some patterns about split & dieing register too.  Means we produce
> weaker code.
So let's dig into this deeper.  Examples & explanations would help.  I 
know it feels like a bit of a runaround, but avoiding adding the pass 
would be good.

jeff
diff mbox

Patch

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: passes.def
===================================================================
--- passes.def    (Revision 211850)
+++ passes.def    (Arbeitskopie)
@@ -393,6 +393,7 @@  along with GCC; see the file COPYING3.  If not see
       NEXT_PASS (pass_reorder_blocks);
       NEXT_PASS (pass_branch_target_load_optimize2);
       NEXT_PASS (pass_leaf_regs);
+      NEXT_PASS (pass_peephole2);
       NEXT_PASS (pass_split_before_sched2);
       NEXT_PASS (pass_sched2);
       NEXT_PASS (pass_stack_regs);
Index: config/i386/i386.md
===================================================================
--- config/i386/i386.md    (Revision 211850)
+++ config/i386/i386.md    (Arbeitskopie)
@@ -11466,6 +11466,15 @@ 
                 (match_dup 4)))
           (unspec [(const_int 0)] UNSPEC_PEEPSIB)])])

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

 (define_expand "call_value"