From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id BE188385700B; Wed, 27 Jul 2022 09:24:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BE188385700B MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-8627] Fix tree-opt/PR106087: ICE with inline-asm with multiple output and assigned only static vars X-Act-Checkin: gcc X-Git-Author: Andrew Pinski X-Git-Refname: refs/heads/releases/gcc-12 X-Git-Oldrev: 019a9ef7f7466c0f41bdc8c5838f4f4926c938aa X-Git-Newrev: e0e388998b797da09a8c018f6f94d1358fd4b8f1 Message-Id: <20220727092424.BE188385700B@sourceware.org> Date: Wed, 27 Jul 2022 09:24:24 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jul 2022 09:24:24 -0000 https://gcc.gnu.org/g:e0e388998b797da09a8c018f6f94d1358fd4b8f1 commit r12-8627-ge0e388998b797da09a8c018f6f94d1358fd4b8f1 Author: Andrew Pinski Date: Thu Jul 7 22:06:19 2022 +0000 Fix tree-opt/PR106087: ICE with inline-asm with multiple output and assigned only static vars 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. Committed as approved after a 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. (cherry picked from commit 71e3daa31cfa35ee58e5899cb00767be92227fd2) Diff: --- gcc/testsuite/gcc.c-torture/compile/inline-asm-1.c | 14 ++++++++++++++ gcc/tree-ssa-dce.cc | 7 +++++++ 2 files changed, 21 insertions(+) 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 2067b711d5b..4b7b664867d 100644 --- a/gcc/tree-ssa-dce.cc +++ b/gcc/tree-ssa-dce.cc @@ -2060,6 +2060,13 @@ simple_dce_from_worklist (bitmap worklist) if (gimple_has_side_effects (t)) continue; + /* The defining statement needs to be defining only this name. + ASM is the only statement that can define more than one + (non-virtual) name. */ + if (is_a(t) + && !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))