This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch i386]: Combine memory and indirect jump
- From: Kai Tietz <ktietz70 at googlemail dot com>
- To: Jeff Law <law at redhat dot com>
- Cc: Richard Henderson <rth at redhat dot com>, Steven Bosscher <stevenb dot gcc at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 20 Jun 2014 17:56:10 +0200
- Subject: Re: [patch i386]: Combine memory and indirect jump
- Authentication-results: sourceware.org; auth=none
- References: <CAEwic4brJeBvoe+J5ss=Qo+=qoo-=2nV0FnjdUxBhm-fV4aqeQ at mail dot gmail dot com> <CABu31nNwUoLaAo0QcD-3O1QYhBWpLsYuH0cMS-XOgz2W+8KMAA at mail dot gmail dot com> <CAEwic4Zwd4HECD+kxtkouyA3Urbyzh2NFar7kZ5XLdNnUK9w6A at mail dot gmail dot com> <CAEwic4anzQysfHqfQGgKF_Hu-c_hLY+mkWr2CzERVe=gQ5AWRw at mail dot gmail dot com> <539B1A7F dot 8020200 at redhat dot com> <539B1F1E dot 3000809 at redhat dot com> <539B1FA4 dot 4070803 at redhat dot com> <CAEwic4aDiZ_42ddHSKjoLHhrb6oMhds1p0jJZQHFMFc6x4_DfQ at mail dot gmail dot com> <53A0964B dot 4040304 at redhat dot com> <CAEwic4aELa35-+vaivscNz3vTpAEAxb+FHRj2ODtM8VmNSGyPA at mail dot gmail dot com> <53A1EA3A dot 8000100 at redhat dot com>
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
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"