From patchwork Sun Apr 5 08:45:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yvan Roux X-Patchwork-Id: 46779 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 85FBD21495 for ; Sun, 5 Apr 2015 08:45:32 +0000 (UTC) Received: by lbbug6 with SMTP id ug6sf1178952lbb.3 for ; Sun, 05 Apr 2015 01:45:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mailing-list:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:sender :delivered-to:mime-version:in-reply-to:references:date:message-id :subject:from:to:cc:content-type:x-original-sender :x-original-authentication-results; bh=EMAAsrEHOjWzIK4VP1t5ZaV2seFGdOdJulX3kRoioMo=; b=F4eZT7T+ZzJZsnfcuOWIlgWckOTUcNLBCmpu6v0qNUr8yTnNiYybk8DsjcfAcVRo4M gTykrEGXQ2HKOU7x2dvBo8ajjtgd7Qr4Hc4okxIKqlbSPoctYZxjzfqErhP3W7tNes+3 CCVtL6CUTzF8abPyUjyvad/Hs+lW0NyBeqmOMgbQvPF8Y+uk2/C5HQiaJErKJBdSUIB3 aASnl53o1ctm1GQn/Eg66VQjcn4VN/IbumcwGjzQWT9ud3GFlvsrWmG/HyJuXi8gx4ml cn7UZmjfNl132lZ56IwyAHypj8rtANhxjIZ/d3oOH4EBcZ6dObwD67fZH44f6c8XI6jc i6XA== X-Gm-Message-State: ALoCoQl/d8lSTHFwC8P1RBL0dZTj/AsQ6hO0AqGvplRTNx01z8A+XII9/ZX49lr6WuXcEk6lIK/A X-Received: by 10.152.206.36 with SMTP id ll4mr2201846lac.6.1428223531256; Sun, 05 Apr 2015 01:45:31 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.197.97 with SMTP id it1ls470646lac.1.gmail; Sun, 05 Apr 2015 01:45:31 -0700 (PDT) X-Received: by 10.112.13.73 with SMTP id f9mr7146592lbc.124.1428223531025; Sun, 05 Apr 2015 01:45:31 -0700 (PDT) Received: from mail-la0-x233.google.com (mail-la0-x233.google.com. [2a00:1450:4010:c03::233]) by mx.google.com with ESMTPS id zg6si822808lbb.169.2015.04.05.01.45.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 Apr 2015 01:45:30 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::233 as permitted sender) client-ip=2a00:1450:4010:c03::233; Received: by lagg8 with SMTP id g8so4319125lag.1 for ; Sun, 05 Apr 2015 01:45:30 -0700 (PDT) X-Received: by 10.112.10.197 with SMTP id k5mr9042643lbb.86.1428223530428; Sun, 05 Apr 2015 01:45:30 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.57.201 with SMTP id k9csp2774258lbq; Sun, 5 Apr 2015 01:45:28 -0700 (PDT) X-Received: by 10.70.55.165 with SMTP id t5mr18138833pdp.102.1428223527984; Sun, 05 Apr 2015 01:45:27 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id yl5si1612244pac.176.2015.04.05.01.45.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 Apr 2015 01:45:27 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-394622-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 25771 invoked by alias); 5 Apr 2015 08:45:10 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 25753 invoked by uid 89); 5 Apr 2015 08:45:07 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ob0-f179.google.com Received: from mail-ob0-f179.google.com (HELO mail-ob0-f179.google.com) (209.85.214.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sun, 05 Apr 2015 08:45:06 +0000 Received: by obbgh1 with SMTP id gh1so8587101obb.1 for ; Sun, 05 Apr 2015 01:45:04 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.182.28.135 with SMTP id b7mr12229948obh.61.1428223504241; Sun, 05 Apr 2015 01:45:04 -0700 (PDT) Received: by 10.202.54.66 with HTTP; Sun, 5 Apr 2015 01:45:04 -0700 (PDT) In-Reply-To: <551FF797.6030302@redhat.com> References: <551FF797.6030302@redhat.com> Date: Sun, 5 Apr 2015 10:45:04 +0200 Message-ID: Subject: Re: patch to fix PR65647 From: Yvan Roux To: Vladimir Makarov Cc: "gcc-patches@gcc.gnu.org" X-IsSubscribed: yes X-Original-Sender: yvan.roux@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::233 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 Hi, The issue is also present in 4.9 branch as explained in: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65647 As 4.9 doesn't contains lra rematerialization passe, we only need to stop updating lra_constraint_new_regno_start when inheritance is switched off. Bootstrapped and tested on x64_64 and cross built and tested on AArch64, arm, armeb and i686. Ok for 4.9 ? Cheers, Yvan 2015-04-05 Yvan Roux Backport from trunk r221867 2015-04-04 Vladimir Makarov PR target/65647 * lra.c (lra): Stop updating lra_constraint_new_regno_start after switching off inheritance. 2015-04-05 Yvan Roux Backport from trunk r221867 2015-04-04 Vladimir Makarov PR target/65647 * gcc.target/arm/pr65647.c: New. * gcc.target/arm/pr65647-2.c: New. On 4 April 2015 at 16:39, Vladimir Makarov wrote: > The following patch fixes > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65647 > > This very complicated problem occurred in rare cases when chain of reloads > involving at least two pseudos and insns were generated and one pseudo was > spilled on later sub-passes after spilling sub-pass and this pattern > happened to be repeated. > > The patch was bootstrapped and tested on x86/x86-64, ppc64, and aarch64. > > Committed as rev.221867. > > 2015-04-04 Vladimir Makarov > > PR target/65647 > * lra-int.h (LRA_MAX_REMATERIALIZATION_PASSES): New. Add its > value checking. > (lra_rematerialization_iter): New. > * lra.c (lra): Initialize lra_rematerialization_iter. > Stop updating lra_constraint_new_regno_start after switching of > inheritance and rematerialization. > * lra-remat.c (lra_rematerialization_iter): New. > (lra_remat): Add printing pass iteration. Do rematerialization > only first LRA_MAX_REMATERIALIZATION_PASSES iterations. > > 2015-04-04 Vladimir Makarov > > PR target/65647 > * gcc.target/arm/pr65647.c: New. > > diff --git a/gcc/lra.c b/gcc/lra.c index 69b08dc..98f0444 100644 --- a/gcc/lra.c +++ b/gcc/lra.c @@ -2417,7 +2417,11 @@ lra (FILE *f) /* Assignment of stack slots changes elimination offsets for some eliminations. So update the offsets here. */ lra_eliminate (false, false); - lra_constraint_new_regno_start = max_reg_num (); + /* After switching off inheritance passe, don't forget reload pseudos + after spilling sub-pass to avoid LRA cycling in some complicated + cases. */ + if (lra_inheritance_iter <= LRA_MAX_INHERITANCE_PASSES) + lra_constraint_new_regno_start = max_reg_num (); lra_constraint_new_insn_uid_start = get_max_uid (); lra_assignment_iter_after_spill = 0; } diff --git a/gcc/testsuite/gcc.target/arm/pr65647-2.c b/gcc/testsuite/gcc.target/arm/pr65647-2.c new file mode 100644 index 0000000..f2985f8 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pr65647-2.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -marm -march=armv6 -std=c99" } */ + +typedef struct { + int i; +} x264_union32_t; +typedef struct { + int level_idx; +} trellis_node_t; +int a, c, d, f, h, i = (int)&c; +trellis_node_t b[1][1]; +short *e = 0; +short g; +void fn1() { + int k[64 * 8 * 2]; + trellis_node_t *l = b[0]; + for (; i >= d; i--) { + if (e[i]) { + for (int j = 1; j < 8; j++) { + ((x264_union32_t *)&k[a])->i = l[j].level_idx; + l[j].level_idx = a; + a++; + } + continue; + } + for (int j;; j++) + ; + } + int m[6] __attribute__((aligned(16))); + for (; h; h++, f++) + g = m[h]; +} diff --git a/gcc/testsuite/gcc.target/arm/pr65647.c b/gcc/testsuite/gcc.target/arm/pr65647.c new file mode 100644 index 0000000..686eb58 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pr65647.c @@ -0,0 +1,58 @@ +/* { dg-do compile } */ +/* { dg-options "-march=armv6-m -mthumb -O3 -w" } */ + +a, b, c, e, g = &e, h, i = 7, l = 1, m, n, o, q = &m, r, s = &r, u, w = 9, x, + y = 6, z, t6 = 7, t8, t9 = 1, t11 = 5, t12 = &t8, t13 = 3, t15, + t16 = &t15; +struct { + long long f3; + char f4 +} p = {3} + + , + t = {4}; + +struct S1 { + long long f0; + short f1; + long long f2 +} d; +long long f = 4073709551613, t7 = 8, t14 = 4073709551610; +j[]; +k = j; +v = &d; +*t10 = j; +struct S1 fn1(); +struct S1 fn2() { + signed char t1; + struct S1 t2; + long t3 = x; + short t4 = h; + short *t5 = &l; + fn1(t2, w, 1, o); + if (u) { + l = q; + t1 = a < b ?: b; + z = c >= 2 || t1 << c; + } + *t5 = t4 &= t3; + fn3(y); +} + +fn4() { + t6 = t.f3; + fn5(k, t7); +} + +struct S1 fn1() { + f = 0; + for (; i;) + ; + t11 = 0; + t13 = *t10 = t14 || n; + t9 = t12; + for (; p.f4;) + s = t16 <= fn6(); + if (g) + v = 0; +}