From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E02743858C78; Mon, 29 May 2023 19:35:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E02743858C78 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685388908; bh=TeAyWhEaQZCubfxY9poD/84RIevtzqzJG9EfMdeireM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=xbh8uygcgj7aeHuusB7eRZ9fSktkIZVhzoXikvjxVFhItCZsb5AeZDo80fSXhjmJI mOPIjBiyoRHn402T9DyS2AGCE3USlBNFN03UoIyPCy4E1DRzoUI417/H2u5/ixvNZr b1Oi9F3/YBgfM5W+aaBUpY3yFLycj81bxwGQzmvY= From: "gjl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/101188] [postreload] Uses content of a clobbered register Date: Mon, 29 May 2023 19:35:08 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 11.1.0 X-Bugzilla-Keywords: ra, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: gjl at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101188 --- Comment #10 from Georg-Johann Lay --- Created attachment 55189 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D55189&action=3Dedit Proposed patch for postreload.cc so analysis is not bypassing "next" insn. (In reply to Georg-Johann Lay from comment #9) > postreload.cc::reload_cse_move2add() loops over all insns, and at some po= int > it encounters >=20 > (insn 44 14 15 2 (set (reg/f:HI 14 r14 [58]) > (reg/v/f:HI 16 r16 [orig:51 self ] [51])) "fail1.c":28:5 101 > {*movhi_split} > (nil)) >=20 > During the analysis for that insn, it executes >=20 > rtx_insn *next =3D next_nonnote_nondebug_insn (insn); > rtx set =3D NULL_RTX; > if (next) > set =3D single_set (next); >=20 > where next is >=20 > (insn 15 44 16 2 (parallel [ > (set (reg/f:HI 14 r14 [58]) > (plus:HI (reg/f:HI 14 r14 [58]) > (const_int 68 [0x44]))) > (clobber (reg:QI 31 r31)) > ]) "fail1.c":28:5 175 {addhi3_clobber} > (nil)) >=20 > Further down, it continues with success =3D 0: >=20 > if (success) > delete_insn (insn); > changed |=3D success; > insn =3D next; > [...] > continue; >=20 > The scan then continues with NEXT_INSN (insn), which is the insn AFTER in= sn > 15, so the CLOBBER of QI:31 in insn 15 is bypassed, and note_stores or > similar is never executed on insn 15. A simple solution is to not "insn =3D next;" and just to pseudo-delete insn= so that NEXT_INSN (insn) works in the for loop: diff --git a/gcc/postreload.cc b/gcc/postreload.cc index fb392651e1b..388b8c0a506 100644 --- a/gcc/postreload.cc +++ b/gcc/postreload.cc @@ -2031,9 +2031,8 @@ reload_cse_move2add (rtx_insn *first) } } if (success) - delete_insn (insn); + SET_INSN_DELETED (insn); changed |=3D success; - insn =3D next; move2add_record_mode (reg); reg_offset[regno] =3D trunc_int_for_mode (added_offset + base_offset,=