From patchwork Sat Jun 8 18:38:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 249976 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id E5EAE2C02C9 for ; Sun, 9 Jun 2013 04:39:05 +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 :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=aRAAUO1tFXDo0m4t74Vo+6OZBcWU+5g28gxA4MGEJRpyPi ymxsP5vzQs0yfgRFXZuThDkwG5NPt49wilNIvlta0EU30l8iSL5YK7DPjz19mOBR lIzcfO0yIllRL5JON65HqOHNegCTs937iXE9m/mIUDEtus9vqfeCijHBX5wQU= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=gceA8HKwbGx589gI/dbjo/CPrIQ=; b=EQees2DUv5zCKdxA3Wl2 hX+dHwngbPPjOQOKLSav+jyBZn4ZrRdCXsN2N8PpIJPsGSZzQq2keu0TMSv9bDao fWH6cqzoxY4w6med9KW0AwJcLcbGw08YqywO6bATikHfR6Kn3XOqIkKQp5pfMaOj QI5/TedkBZ0LiS7B5Td1sI0= Received: (qmail 28807 invoked by alias); 8 Jun 2013 18:38:59 -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 28795 invoked by uid 89); 8 Jun 2013 18:38:59 -0000 X-Spam-SWARE-Status: No, score=-6.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Sat, 08 Jun 2013 18:38:58 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r58IcvU2000444 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 8 Jun 2013 14:38:57 -0400 Received: from Mair.local (vpn-52-128.rdu2.redhat.com [10.10.52.128]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r58Ict6t010981 for ; Sat, 8 Jun 2013 14:38:56 -0400 Message-ID: <51B37A3F.1060705@redhat.com> Date: Sat, 08 Jun 2013 14:38:55 -0400 From: Vladimir Makarov User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-Version: 1.0 To: GCC Patches Subject: patch to fix PR57559 for s390 X-Virus-Found: No The following patch fixes http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57559 The problem was in systematic discouraging reload symbol address in memory. The patch actually reverts a fix for a x86/x86-64 PR for -fpie. The patch implements another solution for this problem (see changes for lra_emit_add). The patch was successfully bootstrapped and tested on x86/x86-64 and s390. Committed as rev. 199859. 2013-06-08 Vladimir Makarov PR rtl-optimization/57559 * lra-constraints.c (process_alt_operands): Don't discourage memory with known offset for offsetable memory constraint. * lra.c (lra_emit_add): Exchange y and z for 2-op add insn. 2013-06-08 Vladimir Makarov PR rtl-optimization/57559 * gcc.target/s390/pr57559.c : New test. Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 199762) +++ lra-constraints.c (working copy) @@ -1997,15 +1997,8 @@ process_alt_operands (int only_alternati (op, this_alternative) == NO_REGS)))) reject += LRA_MAX_REJECT; - if (MEM_P (op) && offmemok) - { - /* If we know offset and this non-offsetable memory, - something wrong with this memory and it is better - to try other memory possibilities. */ - if (MEM_OFFSET_KNOWN_P (op)) - reject += LRA_MAX_REJECT; - } - else if (! (const_to_mem && constmemok)) + if (! (MEM_P (op) && offmemok) + && ! (const_to_mem && constmemok)) { /* We prefer to reload pseudos over reloading other things, since such reloads may be able to be Index: lra.c =================================================================== --- lra.c (revision 199753) +++ lra.c (working copy) @@ -306,11 +306,11 @@ lra_emit_add (rtx x, rtx y, rtx z) || (disp != NULL_RTX && ! CONSTANT_P (disp)) || (scale != NULL_RTX && ! CONSTANT_P (scale))) { - /* Its is not an address generation. Probably we have no 3 op + /* It is not an address generation. Probably we have no 3 op add. Last chance is to use 2-op add insn. */ lra_assert (x != y && x != z); - emit_move_insn (x, z); - insn = gen_add2_insn (x, y); + emit_move_insn (x, y); + insn = gen_add2_insn (x, z); emit_insn (insn); } else Index: testsuite/gcc.target/s390/pr57559.c =================================================================== --- testsuite/gcc.target/s390/pr57559.c (revision 0) +++ testsuite/gcc.target/s390/pr57559.c (working copy) @@ -0,0 +1,24 @@ +/* PR rtl-optimization/57559 */ + +/* { dg-do compile } */ +/* { dg-options "-march=z10 -m64 -mzarch -O1" } */ + +typedef int int32_t; +typedef unsigned char uint8_t; +typedef unsigned int uint32_t; +struct _IO_marker +{ +}; +static const int32_t mfcone = 1; +static const uint8_t *mfctop = (const uint8_t *) &mfcone; +int32_t +decContextTestEndian (uint8_t quiet) +{ + int32_t res = 0; + uint32_t dle = (uint32_t) 0; + if (*(int *) 10 != 0) + { + res = (int32_t) * mfctop - dle; + } + return res; +}