From patchwork Sun Sep 2 14:20:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 181184 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]) by ozlabs.org (Postfix) with SMTP id ED8F92C0089 for ; Mon, 3 Sep 2012 00:20:45 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1347200446; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Date:From:To:Cc:Subject:Message-ID:Reply-To: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=BiKkwApzmSTK91qfVYEM MdBrBZU=; b=RQKBH7f9h5+r6fu6X5Iuz0Ff/JFtqpGZrxKYS9uYCqe+I/wqnhZw z8D11x3pdZ6qFdjgVS6Fe8o8r5QepkoPhKG+lykmZjvFYyd/vcdr45uVw1PMXBlu 4m9MqMkATMYzHdcZhyMYaqn2AmAkm6mLarpjKXWLXdjb0Afow2pHMSs= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-ExtLoop1:Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To:MIME-Version:Content-Type:Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=vehMbiUug7a3jC6w1A9tsjYzmnPctCq1DIQ0d7ke1i5SEKqqOqxfOUW+Ymiug2 GEqsR1Yk/SrOhWJagohIBCv67kJGOfq1IDU4kZY53BbwO4q9m1oDEMSdmYDviUEW VpjZxeaDSdPnAmrrhasoZZVv8hsfQy+vyrySnYcpBAiDk=; Received: (qmail 2559 invoked by alias); 2 Sep 2012 14:20:42 -0000 Received: (qmail 2545 invoked by uid 22791); 2 Sep 2012 14:20:40 -0000 X-SWARE-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, NO_DNS_FOR_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mga03.intel.com (HELO mga03.intel.com) (143.182.124.21) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 02 Sep 2012 14:20:27 +0000 Received: from azsmga002.ch.intel.com ([10.2.17.35]) by azsmga101.ch.intel.com with ESMTP; 02 Sep 2012 07:20:27 -0700 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([10.3.194.135]) by AZSMGA002.ch.intel.com with ESMTP; 02 Sep 2012 07:20:22 -0700 Received: by gnu-6.sc.intel.com (Postfix, from userid 500) id D8D71804D6; Sun, 2 Sep 2012 07:20:21 -0700 (PDT) Date: Sun, 2 Sep 2012 07:20:21 -0700 From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Cc: Jakub Jelinek , Uros Bizjak Subject: PATCH: PR target/54445: TLS array lookup with negative constant is not combined into a single instruction Message-ID: <20120902142021.GA32216@intel.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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 Hi, When x86-64 TLS support was added by: http://gcc.gnu.org/ml/gcc-patches/2002-10/msg01262.html it didn't allow negative offset. Jakub, do you remember the reason for it? I tested this patch on Linux/x86-64 and used the new GCC to build glibc for x86-64 and x32. There are no regressions. OK to install? Thanks. H.J. ---- gcc/ 2012-09-02 H.J. Lu PR target/54445 * config/i386/predicates.md (x86_64_immediate_operand): Allow negative offset for UNSPEC_DTPOFF/UNSPEC_NTPOFF. gcc/testsuite/ 2012-09-02 H.J. Lu PR target/54445 * gcc.target/i386/pr54445-1.c: New file. * gcc.target/i386/pr54445-2.c: Likewise. diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md index 55e4b56..159594e 100644 --- a/gcc/config/i386/predicates.md +++ b/gcc/config/i386/predicates.md @@ -228,8 +228,7 @@ { case UNSPEC_DTPOFF: case UNSPEC_NTPOFF: - if (offset > 0 - && trunc_int_for_mode (offset, SImode) == offset) + if (trunc_int_for_mode (offset, SImode) == offset) return true; } break; diff --git a/gcc/testsuite/gcc.target/i386/pr54445-1.c b/gcc/testsuite/gcc.target/i386/pr54445-1.c new file mode 100644 index 0000000..72ef84e --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr54445-1.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +__thread unsigned char tls_array[64]; + +unsigned char +__attribute__ ((noinline)) +tls_array_lookup_with_negative_constant(long long int position) { + return tls_array[position - 1]; +} + +int +main () +{ + int i; + + for (i = 0; i < sizeof (tls_array) / sizeof (tls_array[0]); i++) + tls_array[i] = i; + + for (i = 0; i < sizeof (tls_array) / sizeof (tls_array[0]); i++) + if (i != tls_array_lookup_with_negative_constant (i + 1)) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/pr54445-2.c b/gcc/testsuite/gcc.target/i386/pr54445-2.c new file mode 100644 index 0000000..5151c13 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr54445-2.c @@ -0,0 +1,11 @@ +/* { dg-do compile { target { *-*-linux* && { ! { ia32 } } } } } */ +/* { dg-options "-O2 -fno-pic" } */ + +__thread unsigned char tls_array[64]; + +unsigned char +tls_array_lookup_with_negative_constant(long long int position) { + return tls_array[position - 1]; +} + +/* { dg-final { scan-assembler "mov(b|zbl)\[ \t\](%fs:)?tls_array@tpoff-1\\(%" } } */