From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B382D386F455; Fri, 18 Sep 2020 09:52:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B382D386F455 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1600422723; bh=cVKTEnr1tdV6hZ/dLhrDmYtywua79AmTr4YVLx3+ExI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=KNLl6uu1NN2vMRaom+S70fsPtwOQY+tV7x0JmRSgyrncFnu6kNYe7bATJd7izdVdL FC7ysHTU7c3Eoe1lPHtxdYHNxP9RUB/4gSqAmEaT8knGA86us5qM3KfEV6OoNInYR5 jVx8KbZYrcnxI+ACH+7vzxrlrNNm+6c4LjfRN4XA= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/97053] [10/11 Regression] an O2, O3 codegen bug Date: Fri, 18 Sep 2020 09:52:03 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2020 09:52:03 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97053 --- Comment #12 from CVS Commits --- The releases/gcc-9 branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:a24744c1ed89e255f3db5b3981519f538d231886 commit r9-8918-ga24744c1ed89e255f3db5b3981519f538d231886 Author: Jakub Jelinek Date: Wed Sep 16 09:42:33 2020 +0200 store-merging: Consider also overlapping stores earlier in the by bitpos sorting [PR97053] As the testcases show, if we have something like: MEM [&b + 8B] =3D {}; MEM[(short *) &b] =3D 5; _5 =3D *x_4(D); MEM [&b + 2B] =3D _5; MEM[(char *)&b + 16B] =3D 88; MEM[(int *)&b + 20B] =3D 1; then in sort_by_bitpos the stores are almost like in the given order, except the first store is after the =3D _5; store. We can't coalesce the =3D 5; store with =3D _5;, because the latter is = MEM_REF, while the former INTEGER_CST, and we can't coalesce the =3D _5 store wi= th the =3D {} store because the former is MEM_REF, the latter INTEGER_CST. But we happily coalesce the remaining 3 stores, which is wrong, because= the =3D _5; store overlaps those and is in between them in the program orde= r. We already have code to deal with similar cases in check_no_overlap, bu= t we deal only with the following stores in sort_by_bitpos order, not the earlier ones. The following patch checks also the earlier ones. In coalesce_immediate_stores it computes the first one that needs to be checked (all the ones whose bitpos + bitsize is smaller or equal to merged_store->start don't need = to be checked and don't need to be checked even for any following attempts because of the sort_by_bitpos sorting) and the end of that (that is the first s= tore in the merged_store). 2020-09-16 Jakub Jelinek PR tree-optimization/97053 * gimple-ssa-store-merging.c (check_no_overlap): Add FIRST_ORDE= R, START, FIRST_EARLIER and LAST_EARLIER arguments. Return false = if any stores between FIRST_EARLIER inclusive and LAST_EARLIER exclusive has order in between FIRST_ORDER and LAST_ORDER and overlaps th= e to be merged store. (imm_store_chain_info::try_coalesce_bswap): Add FIRST_EARLIER argument. Adjust check_no_overlap caller. (imm_store_chain_info::coalesce_immediate_stores): Add first_earlier and last_earlier variables, adjust them during iterations. Adj= ust check_no_overlap callers, call check_no_overlap even when exten= ding overlapping stores by extra INTEGER_CST stores. * gcc.dg/store_merging_31.c: New test. * gcc.dg/store_merging_32.c: New test. (cherry picked from commit bd909071ac04e94f4b6f0baab64d0687ec55681d)=