From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by sourceware.org (Postfix) with ESMTPS id 7D9303858D1E for ; Tue, 14 Feb 2023 15:08:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7D9303858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-x22e.google.com with SMTP id b30so7163140ljf.1 for ; Tue, 14 Feb 2023 07:08:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=6mlFVv19rIQCC4oXEefY/MtFXLrWshE9kyKj8ACYVic=; b=IBnKRT4FG9uC+eP6yC7pB5I+U8vGot7k+ifWFX7e6QA5LenrG5t+rYQjgMoVrlTeZ+ fbVnK1xHIlRIT5joT5llWrmX727T5O9pxdcCXHu6UD/S4oR4erAZi1nCWsezgjOLpzkf cx7w0npLpMGwc+V7wzbL4CX5b+rYqKsQ4IOfxErBZGmw2xjfkp7/bimpDeiTqGyxeJQJ FMgZPhRpOo0zKoX63pgvI3HpaJItPAQdkZv8flZVknzz6z7kYhVBykdOPrexGKHQ17lP W5xkgTVvMKlC5fdBYjDuxD4B9rv1cIjeJw62P8yNGruw6gk3h2bORtgwn1qdBPohnNfr y8qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6mlFVv19rIQCC4oXEefY/MtFXLrWshE9kyKj8ACYVic=; b=ZpFEVcYWQHfJWXPVD0+iceVONMGTvDjX/NpYThdgXR+arzYB+BvPU5b0u33MSH9X+p DOgPqxR/bAPJnqwrzjTvv+m87mEpprT9si4d6a0CM1JGWH7TTVtBmLrEuafm/Z9a10pN C5OJYywGYoU7/M+XfOrKM9gr2aRRpUQOkHSusuqu6ovCI9ClW7/loNbhpXsPUpMLR1SK 9L3Im9NGHnUjO6vtYAhtgUCyxv/4OZEe9e38vDq+AWkCsyF8mIg8MpXF/noGoU9ztpuy NkivTHpL4vdqceXMu2RuliXT/Nk6x6+WrxCjPrh1s8bXIgezirbzcV4phKe15NR8WSCy jQ2w== X-Gm-Message-State: AO0yUKXxKldBhdCO2xIQ7KuLgsutAuluriLyBr7ZXe2MTZk2k0arI6/F u1S/7eAdSL4wfAgJdZS9NPOCH06K55ksVEC8pHY= X-Google-Smtp-Source: AK7set8st5skQlGcOTYKdYLIaUzZR58mjnCjDvKhAzsQCqaLshCP6FLLv5NOER7DFtqcY5I8VXSmcQ0MrLVZuQdRZNY= X-Received: by 2002:a2e:9903:0:b0:293:30ce:ee59 with SMTP id v3-20020a2e9903000000b0029330ceee59mr309455lji.79.1676387308821; Tue, 14 Feb 2023 07:08:28 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Richard Biener Date: Tue, 14 Feb 2023 16:08:15 +0100 Message-ID: Subject: Re: [PATCH] ipa: Avoid IPA confusing scalar values and single-field aggregates (PR 108679) To: Martin Jambor Cc: GCC Patches , Jan Hubicka , Jan Hubicka Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.6 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, Feb 14, 2023 at 3:50 PM Martin Jambor wrote: > > Hi, > > PR 108679 testcase shows a situation when IPA-CP is able to track a > scalar constant in a single-field structure that is part of a bigger > structure. This smaller struture is however also passed in a few calls > to other functions, but the two same-but-different entities, originally > places at the same offset and with the same size, and this confuses the > mechanism that takes care of handling call statements after IPA-SRA. > > I think that in stage 4 it is best to revert to GCC 12 behavior in this > particular case (when IPA-CP detects a constant in a single-field > structure or a single element array that is part of a bigger aggregate) > and the patch below does that. If accepted, I plan to file a > missed-optimization bug to track that we could use the IPA-CP propagated > value to re-construct the small aggregate arguments. > > Bootstrapped and tested and LTO bootstrapped on x86_64-linux. OK for > master? OK. Richard. > Thanks, > > Martin > > > > > gcc/ChangeLog: > > 2023-02-13 Martin Jambor > > PR ipa/108679 > * ipa-sra.cc (push_param_adjustments_for_index): Do not omit > creation of non-scalar replacements even if IPA-CP knows their > contents. > > gcc/testsuite/ChangeLog: > > 2023-02-13 Martin Jambor > > PR ipa/108679 > * gcc.dg/ipa/pr108679.c: New test. > --- > gcc/ipa-sra.cc | 2 +- > gcc/testsuite/gcc.dg/ipa/pr108679.c | 25 +++++++++++++++++++++++++ > 2 files changed, 26 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gcc.dg/ipa/pr108679.c > > diff --git a/gcc/ipa-sra.cc b/gcc/ipa-sra.cc > index 0495f446bf4..3de7d426b7e 100644 > --- a/gcc/ipa-sra.cc > +++ b/gcc/ipa-sra.cc > @@ -3989,7 +3989,7 @@ push_param_adjustments_for_index (isra_func_summary *ifs, unsigned base_index, > { > ipa_argagg_value_list avl (ipcp_ts); > tree value = avl.get_value (base_index, pa->unit_offset); > - if (value) > + if (value && !AGGREGATE_TYPE_P (pa->type)) > { > if (dump_file) > fprintf (dump_file, " - omitting component at byte " > diff --git a/gcc/testsuite/gcc.dg/ipa/pr108679.c b/gcc/testsuite/gcc.dg/ipa/pr108679.c > new file mode 100644 > index 00000000000..b1ed50bb831 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/ipa/pr108679.c > @@ -0,0 +1,25 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O2" } */ > + > +struct S1 { > + signed f0; > +}; > +struct S2 { > + struct S1 f2; > + short f8; > +} g_18; > +void safe_lshift_func_int16_t_s_u(); > +void safe_unary_minus_func_uint64_t_u(); > +int safe_mul_func_uint8_t_u_u(int, struct S1 p_14); > +int g_732, func_6_l_17; > +static int *func_12(); > +static int func_6(struct S2 p_7) { func_12(func_6_l_17, p_7.f2, g_18, 0); } > +static int *func_12(int, struct S1 p_14) { > + safe_lshift_func_int16_t_s_u(); > + safe_unary_minus_func_uint64_t_u(); > + g_732 = safe_mul_func_uint8_t_u_u(0, p_14); > +} > +int main() { > + struct S2 l_10 = {3}; > + func_6(l_10); > +} > -- > 2.39.1 >