From patchwork Wed Nov 30 17:39:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 85903 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp334785qgi; Wed, 30 Nov 2016 09:40:21 -0800 (PST) X-Received: by 10.84.175.3 with SMTP id s3mr74419528plb.66.1480527621621; Wed, 30 Nov 2016 09:40:21 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id a2si65248920pgf.207.2016.11.30.09.40.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Nov 2016 09:40:21 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-443107-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-443107-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-443107-patch=linaro.org@gcc.gnu.org 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=I6Pp2V6dITi5CAUPf6uvzDkmjYfCwCqbE8Zz7spOBlqM5/ZAxa LJVwb5Ood2BuBAj3vDIAh1g1oJBXwqlzMYTJWCXDoTgoljZmo9yNGjWUwfmWs0MH 8E7TlfG3TK4a94JHLOQWD9kH3yS33lIkoJ5FEW+eAeBdYi6zANA9ei18A= 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=kHnUw5Wyp7z2y4YaAIMjhT/0uH0=; b=YiLGOqOWXZYu0QXbSt8P WFLS0SrrhqMFxFzzXpnRTMITco7f6GX7UEsQpFHBq9yVNtwTxfgO15c+PjBqhaHi OanEVu5O+S2hLt7NrvQ8Y7gPiuEn5vvIYvNMyLcs4sQyL7C6393wNxEG3bFqdpaD QaExP9gDUHt7vioXv/IXwRQ= Received: (qmail 17444 invoked by alias); 30 Nov 2016 17:39:55 -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 17391 invoked by uid 89); 30 Nov 2016 17:39:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.0 required=5.0 tests=BAYES_00, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=vehregccgnuorg, vehre@gcc.gnu.org, sk:vehreg, summer 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 ESMTP; Wed, 30 Nov 2016 17:39:44 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (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 33C5280518 for ; Wed, 30 Nov 2016 17:39:43 +0000 (UTC) Received: from brix.home (ovpn-112-27.phx2.redhat.com [10.3.112.27]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uAUHdfBE019428 for ; Wed, 30 Nov 2016 12:39:42 -0500 To: "gcc-patches@gcc.gnu.org" From: Vladimir N Makarov Subject: patch to fix PR77856 Message-ID: <24602e7b-6f5d-89c4-8ca1-bd7ca6646570@redhat.com> Date: Wed, 30 Nov 2016 12:39:40 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 X-IsSubscribed: yes The following patch fixes https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77856 The bug was in a new code for invariant inheritance I added this summer. The patch was successfully bootstrapped and tested on x86-64. Committed as rev. 243038. Index: ChangeLog =================================================================== --- ChangeLog (revision 243034) +++ ChangeLog (working copy) @@ -1,3 +1,10 @@ +2016-11-30 Vladimir Makarov + + PR tree-optimization/77856 + * lra-constraints.c (inherit_in_ebb): Check original regno for + invalid invariant regs too. Set only clobbered hard regs for the + invalid invariant regs. + 2016-11-30 Pitchumani Sivanupandi Commit files forgotten in r242966. Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 242848) +++ lra-constraints.c (working copy) @@ -5886,7 +5886,9 @@ inherit_in_ebb (rtx_insn *head, rtx_insn && dst_regno >= lra_constraint_new_regno_start && invariant_p (SET_SRC (curr_set)) && (cl = lra_get_allocno_class (dst_regno)) != NO_REGS - && ! bitmap_bit_p (&invalid_invariant_regs, dst_regno)) + && ! bitmap_bit_p (&invalid_invariant_regs, dst_regno) + && ! bitmap_bit_p (&invalid_invariant_regs, + ORIGINAL_REGNO(regno_reg_rtx[dst_regno]))) { /* 'reload_pseudo <- invariant'. */ if (ira_class_hard_regs_num[cl] <= max_small_class_regs_num) @@ -6157,16 +6159,20 @@ inherit_in_ebb (rtx_insn *head, rtx_insn curr_id = lra_get_insn_recog_data (curr_insn); for (reg = curr_id->regs; reg != NULL; reg = reg->next) if (reg->type != OP_IN) - bitmap_set_bit (&invalid_invariant_regs, reg->regno); + { + bitmap_set_bit (&invalid_invariant_regs, reg->regno); + bitmap_set_bit (&invalid_invariant_regs, + ORIGINAL_REGNO (regno_reg_rtx[reg->regno])); + } curr_static_id = curr_id->insn_static_data; for (reg = curr_static_id->hard_regs; reg != NULL; reg = reg->next) if (reg->type != OP_IN) bitmap_set_bit (&invalid_invariant_regs, reg->regno); if (curr_id->arg_hard_regs != NULL) for (i = 0; (regno = curr_id->arg_hard_regs[i]) >= 0; i++) + if (regno >= FIRST_PSEUDO_REGISTER) bitmap_set_bit (&invalid_invariant_regs, - regno >= FIRST_PSEUDO_REGISTER - ? regno : regno - FIRST_PSEUDO_REGISTER); + regno - FIRST_PSEUDO_REGISTER); } /* We reached the start of the current basic block. */ if (prev_insn == NULL_RTX || prev_insn == PREV_INSN (head) Index: testsuite/ChangeLog =================================================================== --- testsuite/ChangeLog (revision 243034) +++ testsuite/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2016-11-30 Vladimir Makarov + + PR tree-optimization/77856 + * gcc.target/i386.c (pr77856.c): New. + 2016-11-30 Andre Vehreschild Now really add the file. Index: testsuite/gcc.target/i386/pr77856.c =================================================================== --- testsuite/gcc.target/i386/pr77856.c (revision 0) +++ testsuite/gcc.target/i386/pr77856.c (working copy) @@ -0,0 +1,83 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); + +unsigned a, e; + +struct S0 +{ + int f1; + int f8; +} c = {4, 6}; + +int b, f, g, h, i, j, l, p; +short d, o = -7; +char k, n = 5; + +unsigned fn1 (int p1, int p2) +{ + return p2 >= 2 || p1 >> p2 ? p1 : p1 << p2; +} + +static short fn2 (struct S0 p1) +{ + int *q = 0; + int r = 7; + if (!a) + { + c.f1 = 1; + for (; c.f1; c.f1--) + if (fn1 (10 != 0, p1.f8)) + { + short s = 9 << ~o % (d ^ n); + int t = s >> h % ~d; + p = r; + r = s | p * (d && 9) | t; + int u = i & c.f1; + unsigned v = ~(~(u & h) | (~(8 >> c.f1) & i)); + int w = v; + if (u < 9) + w = c.f1; + if (i > h && u) + { + __builtin_printf ("%d\n", c.f1); + continue; + } + c.f1 = w; + if (!p) + continue; + return 0; + } + for (;;) + *q = 0; + } + return 0; +} + +static void fn3 () +{ + fn2 (c); + l = c.f1 < b; + if (l) + { + L1: + e = l | j / e % ~f; + j = f - 4 % k < c.f1 / e / b - j - 1; + if (l) + { + __builtin_printf ("%d\n", b); + goto L1; + } + int m[245]; + g = m[2]; + } +} + +int main () +{ + fn3 (); + if (c.f1 != 1) + abort (); + return 0; +}