From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id D73A3385840C for ; Wed, 30 Mar 2022 10:04:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D73A3385840C Received: by mail-ej1-x636.google.com with SMTP id yy13so40456284ejb.2 for ; Wed, 30 Mar 2022 03:04:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NA2kGU4mgKSaKyeXi0Nw7mtiPCK53pOYZVQtVBtdcXA=; b=ZcDwFG/rtz2ULzcOyWxja8X6t127umjncHEfjXwyqkFrfRJgb6hkwU4E1VI9IOsu/y 1XX3N7nRX3cu018gaKqjGz2yhSA1uYeGcp7C8g8GL3q+mxLMhn8KxbjzM08h6Xk9euV1 YA0e2iyOQFKWWt7T2/MJzwOsjhLgorXd31/bH3RpMF38s/b0qkLY1/ZlXeadRtxG+YzT W8GTajkOBKEhcc/PXMtPIXDeWtrA9v+syU86YJdUIsY22FZjU3zKXSsDf8d5LeGxwSuM K+A4WVxLUazzEcTBcwzh3awJIyoxChLy+VkfR4G+Mv87v5xUkkfVHTCcMW9ZJO0Bpo43 lzcQ== X-Gm-Message-State: AOAM530UT5qFaLKJ2woQYdxLloz21qmkXZHv0ya3atDMBmdwv3eJWU18 VbsJkDKmEm78N8yx4csIqHJTSdc7RgRuTDzjwSk= X-Google-Smtp-Source: ABdhPJwuYWO8qne6DMU8HFaY78UIKkzcCilwbmPrBwIq+7dKCmG4s1GhV9M9eKigoq96vcMRwhG5ozCL7jijuaT5QsY= X-Received: by 2002:a17:906:948:b0:6d6:e479:1fe4 with SMTP id j8-20020a170906094800b006d6e4791fe4mr38045398ejd.240.1648634653520; Wed, 30 Mar 2022 03:04:13 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Richard Biener Date: Wed, 30 Mar 2022 12:04:02 +0200 Message-ID: Subject: Re: [GCC 9 backport] cplxlower: Avoid a transform when looking at a default definition To: Martin Jambor Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2022 10:04:16 -0000 On Wed, Mar 30, 2022 at 11:52 AM Martin Jambor wrote: > > Hi, > > I did not backport my fix of PR 97456 to GCC 9 and it re-surfaced there > as PR 105071. I have cherry-picked the fix, pasted below, on top of the > gcc 9 branch (the only change is an extra bug reference in the > ChangeLog) and made sure it passes bootstrap and testing on > x86_64-linux. Can I commit the backport to the branch? OK > I think the old testcase is sufficient and so did not add the new one. > > Thanks, > > Martin > > > > > In PR 97456, IPA-SRA triggers a bug in tree-complex.c where it > converts: > > > a$_M_value_21 = COMPLEX_EXPR ; > > (where ISRA.18 is IPA-SRA created PARM_DECL with DECL_IGNORED_P set, > which is why it only happens with IPA-SRA) into: > > > a$_M_value_21 = COMPLEX_EXPR ; > > i.e. it replaces two uses of the parameter default-def with two > uninitialized default-defs of a new variable - all in hope to produce > code with better debug info. > > This patch fixes it by avoiding the transform when the SSA_NAME to be > replaced is a default definition. > > gcc/ChangeLog: > > 2020-10-19 Martin Jambor > > PR tree-optimization/97456 > PR middle-end/105071 > * tree-complex.c (set_component_ssa_name): Do not replace ignored decl > default definitions with new component vars. Reorder if conditions. > > gcc/testsuite/ChangeLog: > > 2020-10-19 Martin Jambor > > PR tree-optimization/97456 > * gcc.dg/tree-ssa/pr97456.c: New test. > > (cherry picked from commit 619f91eaa8c8a50f1f9d3e7b96ee837037f0e806) > --- > gcc/testsuite/gcc.dg/tree-ssa/pr97456.c | 40 +++++++++++++++++++++++++ > gcc/tree-complex.c | 3 +- > 2 files changed, 42 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr97456.c > > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr97456.c b/gcc/testsuite/gcc.dg/tree-ssa/pr97456.c > new file mode 100644 > index 00000000000..5171c9b4577 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr97456.c > @@ -0,0 +1,40 @@ > +/* { dg-do run } */ > +/* { dg-options "-O2 -fwhole-program" } */ > + > + > +float val2 = 1.710780f; > +float val3; > +volatile float vf; > + > +int __attribute__((noipa)) > +get_bool (void) > +{ > + return 1; > +} > + > +int __attribute__((noinline)) > +wrong (float *pos) > +{ > + _Complex float a; > + > + __real__ a = *pos; > + __imag__ a = *pos; > + > + _Complex float b = 0 + 0i; > + > + b = b + a; > + > + if (b == 0.0f) > + return 1; > + > + vf = __imag__ b; > + return 0; > +} > + > +int main(int argc, char **argv) { > + float val = get_bool () == 1 ? val2 : val3; > + > + if ((wrong(&val), wrong(&val))) > + __builtin_abort (); > + return 0; > +} > diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c > index d4b053d68e1..36a4d6f06d5 100644 > --- a/gcc/tree-complex.c > +++ b/gcc/tree-complex.c > @@ -569,7 +569,8 @@ set_component_ssa_name (tree ssa_name, bool imag_p, tree value) > { > /* Replace an anonymous base value with the variable from cvc_lookup. > This should result in better debug info. */ > - if (SSA_NAME_VAR (ssa_name) > + if (!SSA_NAME_IS_DEFAULT_DEF (value) > + && SSA_NAME_VAR (ssa_name) > && (!SSA_NAME_VAR (value) || DECL_IGNORED_P (SSA_NAME_VAR (value))) > && !DECL_IGNORED_P (SSA_NAME_VAR (ssa_name))) > { > -- > 2.35.1 >