From patchwork Thu Dec 17 16:49:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 558425 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 523CD1402BF for ; Fri, 18 Dec 2015 03:50:02 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=D55mMneY; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=xo2/l9cvOAgvhiKSf+MRpJMShQLBz ytRUJMf9lQq1FtsGFl6zluY/7WnLm9gqF9v2INmdU7HXzPi7QgR1nscNuBJ11jpZ oXnDJ/u0PgqNXTBkvfnAiW4HRjDa5Qj3bDlOI/okkOWNciMDNsdA0pq/o92OGyMH b2/4x4RYG05b+E= 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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=uiueieZHzMBm3ijmD1g/RQ1riFs=; b=D55 mMneYcvtagX2R9ZE12aNOLWCXD53HkPSqX03P6FpqhVd/5CzjdAykqnR+/VwDJAH D7TDUFzmlVpmCmRV21la0sYrFBGi+7Sxcp7wjDLVo1uyMv0omb8AISrX6FVe0RNW lwpv7i9xSBSNXklFKDzlfEj8clwXR/Y+7pnygiGU= Received: (qmail 77107 invoked by alias); 17 Dec 2015 16:49:54 -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 77096 invoked by uid 89); 17 Dec 2015 16:49:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, NO_DNS_FOR_FROM, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=H*R:D*gmail.com X-HELO: mga01.intel.com Received: from mga01.intel.com (HELO mga01.intel.com) (192.55.52.88) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 17 Dec 2015 16:49:52 +0000 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP; 17 Dec 2015 08:49:51 -0800 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([172.25.70.52]) by orsmga003.jf.intel.com with ESMTP; 17 Dec 2015 08:49:50 -0800 Received: by gnu-6.sc.intel.com (Postfix, from userid 1000) id 37AA72009AD; Thu, 17 Dec 2015 08:49:50 -0800 (PST) Date: Thu, 17 Dec 2015 08:49:50 -0800 From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Cc: Uros Bizjak Subject: PATCH: PR target/66232: -fPIC -fno-plt -mx32 fails to generate indirect branch via GOT Message-ID: <20151217164950.GA24079@intel.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Since Pmode is 64-bit with -maddress-mode=long for x32, indirect call via GOT slot doesn't need zero_extend. This patch limits *call_got_x32 and *call_value_got_x32 patterns to 32-bit Pmode, adds *call_got_x32_long and *call_value_got_x32_long for 64-bit Pmode. OK for trunk if there is no regression? H.J. --- gcc/ PR target/66232 * config/i386/i386.md (*call_got_x32): Limited to 32-bit Pmode. (*call_value_got_x32): Likewise. (*call_got_x32_long): New pattern. (call_value_got_x32_long): Likewise. gcc/testsuite/ PR target/66232 * gcc.target/i386/pr66232-10.c: New test. * gcc.target/i386/pr66232-11.c: Likewise. * gcc.target/i386/pr66232-12.c: Likewise. * gcc.target/i386/pr66232-13.c: Likewise. --- gcc/config/i386/i386.md | 19 +++++++++++++++++-- gcc/testsuite/gcc.target/i386/pr66232-10.c | 13 +++++++++++++ gcc/testsuite/gcc.target/i386/pr66232-11.c | 14 ++++++++++++++ gcc/testsuite/gcc.target/i386/pr66232-12.c | 13 +++++++++++++ gcc/testsuite/gcc.target/i386/pr66232-13.c | 13 +++++++++++++ 5 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr66232-10.c create mode 100644 gcc/testsuite/gcc.target/i386/pr66232-11.c create mode 100644 gcc/testsuite/gcc.target/i386/pr66232-12.c create mode 100644 gcc/testsuite/gcc.target/i386/pr66232-13.c diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 49b2216..dc61050 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -11861,7 +11861,14 @@ [(call (mem:QI (zero_extend:DI (match_operand:SI 0 "GOT_memory_operand" "Bg"))) (match_operand 1))] - "TARGET_X32" + "TARGET_X32 && Pmode == SImode" + "* return ix86_output_call_insn (insn, operands[0]);" + [(set_attr "type" "call")]) + +(define_insn "*call_got_x32_long" + [(call (mem:QI (match_operand:DI 0 "GOT_memory_operand" "Bg")) + (match_operand 1))] + "TARGET_X32 && Pmode == DImode" "* return ix86_output_call_insn (insn, operands[0]);" [(set_attr "type" "call")]) @@ -12038,7 +12045,15 @@ (zero_extend:DI (match_operand:SI 1 "GOT_memory_operand" "Bg"))) (match_operand 2)))] - "TARGET_X32" + "TARGET_X32 && Pmode == SImode" + "* return ix86_output_call_insn (insn, operands[1]);" + [(set_attr "type" "callv")]) + +(define_insn "*call_value_got_x32_long" + [(set (match_operand 0) + (call (mem:QI (match_operand:DI 1 "GOT_memory_operand" "Bg")) + (match_operand 2)))] + "TARGET_X32 && Pmode == DImode" "* return ix86_output_call_insn (insn, operands[1]);" [(set_attr "type" "callv")]) diff --git a/gcc/testsuite/gcc.target/i386/pr66232-10.c b/gcc/testsuite/gcc.target/i386/pr66232-10.c new file mode 100644 index 0000000..c4e9157 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr66232-10.c @@ -0,0 +1,13 @@ +/* { dg-do compile { target *-*-linux* } } */ +/* { dg-require-effective-target maybe_x32 } */ +/* { dg-options "-O2 -mx32 -fpic -fno-plt -maddress-mode=long" } */ + +extern void bar (void); + +void +foo (void) +{ + bar (); +} + +/* { dg-final { scan-assembler "jmp\[ \t\]*.bar@GOTPCREL" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr66232-11.c b/gcc/testsuite/gcc.target/i386/pr66232-11.c new file mode 100644 index 0000000..05794af --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr66232-11.c @@ -0,0 +1,14 @@ +/* { dg-do compile { target *-*-linux* } } */ +/* { dg-require-effective-target maybe_x32 } */ +/* { dg-options "-O2 -mx32 -fpic -fno-plt -maddress-mode=long" } */ + +extern void bar (void); + +int +foo (void) +{ + bar (); + return 0; +} + +/* { dg-final { scan-assembler "call\[ \t\]*.bar@GOTPCREL" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr66232-12.c b/gcc/testsuite/gcc.target/i386/pr66232-12.c new file mode 100644 index 0000000..313b9e4 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr66232-12.c @@ -0,0 +1,13 @@ +/* { dg-do compile { target *-*-linux* } } */ +/* { dg-require-effective-target maybe_x32 } */ +/* { dg-options "-O2 -mx32 -fpic -fno-plt -maddress-mode=long" } */ + +extern int bar (void); + +int +foo (void) +{ + return bar (); +} + +/* { dg-final { scan-assembler "jmp\[ \t\]*.bar@GOTPCREL" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr66232-13.c b/gcc/testsuite/gcc.target/i386/pr66232-13.c new file mode 100644 index 0000000..50a12cf --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr66232-13.c @@ -0,0 +1,13 @@ +/* { dg-do compile { target *-*-linux* } } */ +/* { dg-require-effective-target maybe_x32 } */ +/* { dg-options "-O2 -mx32 -fpic -fno-plt -maddress-mode=long" } */ + +extern int bar (void); + +int +foo (void) +{ + return bar () + 1; +} + +/* { dg-final { scan-assembler "call\[ \t\]*.bar@GOTPCREL" } } */