diff mbox

[i386] : Combine memory and indirect jump

Message ID CAEwic4bUy7buVoOEPDnKVJ=c3DfmpXEjmxgRoqDg0c+MmJFLUA@mail.gmail.com
State New
Headers show

Commit Message

Kai Tietz June 20, 2014, 3:56 p.m. UTC
I tested variant to use additional the split pass for memory combining
for indirect jumps.  By this we don't need to add a second peephole2
pass.  Other advantage of this version is that even for -O1 we do
combining.

ChangeLog

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

    PR target/39284
    * 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.  Ok for apply?

Regards,
Kai

Comments

Richard Henderson June 20, 2014, 5:23 p.m. UTC | #1
On 06/20/2014 08:56 AM, Kai Tietz wrote:
> +(define_split
> +  [(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))])
> +

Huh?  You can't use peep2 data structures in split passes.


r~
Kai Tietz June 20, 2014, 5:45 p.m. UTC | #2
2014-06-20 19:23 GMT+02:00 Richard Henderson <rth@redhat.com>:
> On 06/20/2014 08:56 AM, Kai Tietz wrote:
>> +(define_split
>> +  [(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))])
>> +
>
> Huh?  You can't use peep2 data structures in split passes.
>
>
> r~

Duh, you are right ... that shouldn't work, nevertheless it
bootstrapped fine.  Well, so we will need second peephole2 pass.  I
will come with patch for that soon.

Kai
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: config/i386/i386.md
===================================================================
--- config/i386/i386.md    (Revision 211850)
+++ config/i386/i386.md    (Arbeitskopie)
@@ -11466,6 +11466,24 @@ 
                 (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))])
+
+;; For avoiding a second pass for peephole, we use here split pass
+
+(define_split
+  [(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"