From patchwork Tue Apr 19 02:54:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 611960 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 3qpqPZ5bBWz9t48 for ; Tue, 19 Apr 2016 12:55:14 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=fiJkwfbB; 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:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=P6d5vMzC0U1Exu3IDzdnwZfO8mJHPm8g75GjJaRlU7/cEOX9uD i2XoGGygxuxsuYlSmI3k4HR13QN30VDSlPL7ljahiTmEH+0ZfaxxednICymIgnky WtKKYVU/6ZfWG0/Jswa+o0zhigVgU0aNi5om70/NUKlEK52YyTDxIKe00= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=NHELry9eQyVdzTdN1e2PScoNdYA=; b=fiJkwfbBl+6P8J0AXuk0 ftvAT1i7hhXj2Pn85ecbKoPZ0waOwy60NL3/QrZC1HhnDQ87LVchTMP3AUMUcPyM 0DqgIpv3BoqkJazbwf5jcITNxl/G1Vb7P7G3ELZrrEbqUk3sHsJ2Hj6WT8zR5dRJ cfs52lhnkzXSW8W/yUeq0Tg= Received: (qmail 30960 invoked by alias); 19 Apr 2016 02:55:06 -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 30933 invoked by uid 89); 19 Apr 2016 02:55:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=BAYES_00, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=curr_insn, five X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 19 Apr 2016 02:54:55 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A21F8C01AA45 for ; Tue, 19 Apr 2016 02:54:54 +0000 (UTC) Received: from brix.home (vpn-55-196.rdu2.redhat.com [10.10.55.196]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3J2srON029562 for ; Mon, 18 Apr 2016 22:54:54 -0400 To: gcc-patches@gcc.gnu.org From: Vladimir N Makarov Subject: patch to fix PR70689 Message-ID: <57159DFD.9060800@redhat.com> Date: Mon, 18 Apr 2016 22:54:53 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 X-IsSubscribed: yes The following patch fixes https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70689 The patch was successfully tested and bootstrapped on x86/x86-64. Committed to the trunk as rev. 235184. Index: ChangeLog =================================================================== --- ChangeLog (revision 235182) +++ ChangeLog (working copy) @@ -1,3 +1,11 @@ +2016-04-18 Vladimir Makarov + + PR middle-end/70689 + * lra-constraints.c (equiv_substition_p): New. + (process_alt_operands): Use it. + (swap_operands): Swap it. + (curr_insn_transform): Update it. + 2016-04-18 Michael Matz * tree.h (TYPE_ALIGN, DECL_ALIGN): Return shifted amount. Index: testsuite/ChangeLog =================================================================== --- testsuite/ChangeLog (revision 235182) +++ testsuite/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2016-04-18 Vladimir Makarov + + PR middle-end/70689 + * testsuite/gcc.target/i386/pr70689.c: New. + 2016-04-18 H.J. Lu PR target/70708 Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 235176) +++ lra-constraints.c (working copy) @@ -1258,6 +1258,10 @@ static bool goal_alt_swapped; /* The chosen insn alternative. */ static int goal_alt_number; +/* True if the corresponding operand is the result of an equivalence + substitution. */ +static bool equiv_substition_p[MAX_RECOG_OPERANDS]; + /* The following five variables are used to choose the best insn alternative. They reflect final characteristics of the best alternative. */ @@ -2064,7 +2068,10 @@ process_alt_operands (int only_alternati memory, or make other memory by reloading the address like for 'o'. */ if (CONST_POOL_OK_P (mode, op) - || MEM_P (op) || REG_P (op)) + || MEM_P (op) || REG_P (op) + /* We can restore the equiv insn by a + reload. */ + || equiv_substition_p[nop]) badop = false; constmemok = true; offmemok = true; @@ -3371,6 +3378,7 @@ swap_operands (int nop) std::swap (curr_operand_mode[nop], curr_operand_mode[nop + 1]); std::swap (original_subreg_reg_mode[nop], original_subreg_reg_mode[nop + 1]); std::swap (*curr_id->operand_loc[nop], *curr_id->operand_loc[nop + 1]); + std::swap (equiv_substition_p[nop], equiv_substition_p[nop + 1]); /* Swap the duplicates too. */ lra_update_dup (curr_id, nop); lra_update_dup (curr_id, nop + 1); @@ -3473,8 +3481,10 @@ curr_insn_transform (bool check_only_p) old = SUBREG_REG (old); subst = get_equiv_with_elimination (old, curr_insn); original_subreg_reg_mode[i] = VOIDmode; + equiv_substition_p[i] = false; if (subst != old) { + equiv_substition_p[i] = true; subst = copy_rtx (subst); lra_assert (REG_P (old)); if (GET_CODE (op) != SUBREG) Index: testsuite/gcc.target/i386/pr70689.c =================================================================== --- testsuite/gcc.target/i386/pr70689.c (revision 0) +++ testsuite/gcc.target/i386/pr70689.c (working copy) @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target ia32 } */ +/* { dg-options "-O1" } */ + +struct S +{ + int f; +}; + +double a; +int c; + +static +void fn1 (struct S *p1) +{ + for (; c; ) + if (p1->f++) + a = (int) p1; +} + +int +main () +{ + struct S b = { 0 }; + fn1 (&b); + return 0; +}