From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by sourceware.org (Postfix) with ESMTPS id 4C17C384F025 for ; Fri, 8 Jul 2022 07:15:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4C17C384F025 Received: by mail-qk1-x72a.google.com with SMTP id o26so8014516qkl.6 for ; Fri, 08 Jul 2022 00:15:51 -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=xMUSUEqdTUnayHx5j93ttySn7ypdFleLsv8Vg3S250E=; b=K0NgnO+uy+DBT1Z4nKqK1swrKM/vXbdq7WmhSiVygAm1yagV5w30vi3pi+TtVoeV+H bBfrDlOHzlzUKMgdW0mzHi84GdEqMXbYQz4JtsOpFZFDU/sFzYk+WFhP7DE/2qfumniI CtVP4TQQqZ9CbDW53xg0EdIg8ElwnZFuGaTql/Pixw9Unt2KLqjlNqa3oaEwsW5mZFrc 9gRoMAlGF7phsRP7VfW1PxlFvd8fC/gFXCwrSzmss6ylZn4FGhNaO0RBiOsa3CoLLE7y qsTMrhn82EyG0ad4WP0AjJFkXYg/LmLVUyVDQghgy1hVQWLb8JNmXT7PCEnfx8AXCDB9 D2/w== X-Gm-Message-State: AJIora+DDH1u7PwkhOuMZYSUtvA1/PXEIwHW1CKnB2G6m/mPocY7hyWa rK3yCbu38nwsKk3s/gamEoVzYRCZHUFm1uP6pPONLz5v X-Google-Smtp-Source: AGRyM1tCxX2PiFEn6BjSkifKKHsgYQA9CXy6k5d/Z5jnvEWSn1GqobNSnx6TEgjgmmbdj3sO8qFk84KgjQaieRYRR+w= X-Received: by 2002:a05:620a:2903:b0:6af:41a4:3f71 with SMTP id m3-20020a05620a290300b006af41a43f71mr1329880qkp.350.1657264550581; Fri, 08 Jul 2022 00:15:50 -0700 (PDT) MIME-Version: 1.0 References: <1657254735-24296-1-git-send-email-apinski@marvell.com> In-Reply-To: <1657254735-24296-1-git-send-email-apinski@marvell.com> From: Richard Biener Date: Fri, 8 Jul 2022 09:15:39 +0200 Message-ID: Subject: Re: [PATCH] Fix tree-opt/PR106087: ICE with inline-asm with multiple output and assigned only static vars To: Andrew Pinski Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.1 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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Fri, 08 Jul 2022 07:15:52 -0000 On Fri, Jul 8, 2022 at 6:33 AM apinski--- via Gcc-patches wrote: > > From: Andrew Pinski > > The problem here is that when we mark the ssa name that was referenced in the now removed > dead store (to a write only static variable), the inline-asm would also be removed > even though it was defining another ssa name. This fixes the problem by checking > to make sure that the statement was only defining one ssa name. > > OK? Bootstrapped and tested on x86_64 with no regressions. > > PR tree-optimization/106087 > > gcc/ChangeLog: > > * tree-ssa-dce.cc (simple_dce_from_worklist): Check > to make sure the statement is only defining one operand. > > gcc/testsuite/ChangeLog: > > * gcc.c-torture/compile/inline-asm-1.c: New test. > --- > gcc/testsuite/gcc.c-torture/compile/inline-asm-1.c | 14 ++++++++++++++ > gcc/tree-ssa-dce.cc | 5 +++++ > 2 files changed, 19 insertions(+) > create mode 100644 gcc/testsuite/gcc.c-torture/compile/inline-asm-1.c > > diff --git a/gcc/testsuite/gcc.c-torture/compile/inline-asm-1.c b/gcc/testsuite/gcc.c-torture/compile/inline-asm-1.c > new file mode 100644 > index 00000000000..0044cb761b6 > --- /dev/null > +++ b/gcc/testsuite/gcc.c-torture/compile/inline-asm-1.c > @@ -0,0 +1,14 @@ > +/* PR tree-opt/106087, > + simple_dce_from_worklist would delete the > + inline-asm when it was still being referenced > + by the other ssa name. */ > + > +static int t; > + > +int f(void) > +{ > + int tt, tt1; > + asm("":"=r"(tt), "=r"(tt1)); > + t = tt1; > + return tt; > +} > diff --git a/gcc/tree-ssa-dce.cc b/gcc/tree-ssa-dce.cc > index bc533582673..602cdb30ceb 100644 > --- a/gcc/tree-ssa-dce.cc > +++ b/gcc/tree-ssa-dce.cc > @@ -2061,6 +2061,11 @@ simple_dce_from_worklist (bitmap worklist) > if (gimple_has_side_effects (t)) > continue; > > + /* The defining statement needs to be defining one this name. */ only this name? > + if (!is_a(t) I suppose we could turn this into is_a(t) since that's the only stmt kind with multiple (non-virtual) definitions? OK with those changes. > + && !single_ssa_def_operand (t, SSA_OP_DEF)) > + continue; > + > /* Don't remove statements that are needed for non-call > eh to work. */ > if (stmt_unremovable_because_of_non_call_eh_p (cfun, t)) > -- > 2.17.1 >