From patchwork Fri Jun 20 15:56:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai Tietz X-Patchwork-Id: 362294 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 78CBB140086 for ; Sat, 21 Jun 2014 01:56:20 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; q=dns; s=default; b=rIu8R6C2LiA0CgYGE+ ioF2iEg0IgHDHBr1DuMMXPPR/JPZPJm2KmsWNlK5TirNCE7VW0t7SIWU+ScvvaSM Ll+pJJ7s/4/TGE8pNM+zHXGOwLoY6DHLNSt4mmC+G8p/L4etA+2GJNkXJ9eJAfNs nDH4ImRSk4UdFyR8lgThlAEaw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; s=default; bh=SeUqSWNoWTUNziTMic9yCRDj XXQ=; b=KcDQPRXACll2xG7UuRBakebpFkAHJwwTwYN1S60xzkHsyk9TMJr+wgpO KeHl0nrIFJf6d0IFOJDERY/OEaeUSA7wkqa4fQioinpeg+loEpGQM3QICmDs+LtA 7JBJWkJMPlpJFYLS+/3yFJEGmAhyU1tNR3FYqaY8AO2xIGj5l3o= Received: (qmail 5042 invoked by alias); 20 Jun 2014 15:56:14 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 5030 invoked by uid 89); 20 Jun 2014 15:56:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-qg0-f43.google.com Received: from mail-qg0-f43.google.com (HELO mail-qg0-f43.google.com) (209.85.192.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 20 Jun 2014 15:56:12 +0000 Received: by mail-qg0-f43.google.com with SMTP id z60so3613600qgd.16 for ; Fri, 20 Jun 2014 08:56:10 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.140.41.113 with SMTP id y104mr5924248qgy.34.1403279770548; Fri, 20 Jun 2014 08:56:10 -0700 (PDT) Received: by 10.96.82.162 with HTTP; Fri, 20 Jun 2014 08:56:10 -0700 (PDT) In-Reply-To: <53A1EA3A.8000100@redhat.com> References: <539B1A7F.8020200@redhat.com> <539B1F1E.3000809@redhat.com> <539B1FA4.4070803@redhat.com> <53A0964B.4040304@redhat.com> <53A1EA3A.8000100@redhat.com> Date: Fri, 20 Jun 2014 17:56:10 +0200 Message-ID: Subject: Re: [patch i386]: Combine memory and indirect jump From: Kai Tietz To: Jeff Law Cc: Richard Henderson , Steven Bosscher , GCC Patches X-IsSubscribed: yes 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 PR target/39284 * config/i386/i386.md (peehole2): To combine indirect jump with memory. (split2): Likewise. 2014-06-20 Kai Tietz * 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"