From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E54A93858C60; Sat, 9 Mar 2024 12:05:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E54A93858C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709985916; bh=P96ZRdeEJnxE9F6FnkqJQKTofY/+eY6QCJenpiJH9sI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=xD4Zjv2g+T1/rsxe3/bxwlWMSYV4k111K5c/EkXAntuBwR5ulzHaT38CPT255YFMi FxOgk0/FQ/T64scP4/3rAMvIRShcz47Cd30qPnYQPc/JI2tc3OazaiP6uDvcpHlcyA NRUYtQyEiKggCykb35QzUQkfY9YJky7O9+84Vu1Q= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/114284] [14 Regression] arm: Load of volatile short gets miscompiled (loaded twice) since r14-8319 Date: Sat, 09 Mar 2024 12:05:12 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.0 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114284 --- Comment #7 from GCC Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:3e3e4156a5f93e6d62101594ca6660ee9ce9c10e commit r14-9412-g3e3e4156a5f93e6d62101594ca6660ee9ce9c10e Author: Jakub Jelinek Date: Sat Mar 9 13:04:26 2024 +0100 fwprop: Restore previous behavior for forward propagation of RTL with M= EMs [PR114284] Before the recent PR111267 r14-8319 fwprop changes, fwprop would never = try to propagate what was not considered PROFITABLE, where the profitable p= art actually was partly about profitability, partly about very good reasons not to actually propagate and partly for cases where propagation is completely incorrect. In particular, classify_result has: /* Allow (subreg (mem)) -> (mem) simplifications with the following exceptions: 1) Propagating (mem)s into multiple uses is not profitable. 2) Propagating (mem)s across EBBs may not be profitable if the sou= rce EBB runs less frequently. 3) Propagating (mem)s into paradoxical (subreg)s is not profitable. 4) Creating new (mem/v)s is not correct, since DCE will not remove= the old ones. */ if (single_use_p && single_ebb_p && SUBREG_P (old_rtx) && !paradoxical_subreg_p (old_rtx) && MEM_P (new_rtx) && !MEM_VOLATILE_P (new_rtx)) return PROFITABLE; and didn't mark any other MEM_P (new_rtx) or rtxes which contain a MEM in its subrtxes as PROFITABLE. Now, since r14-8319 profitable_p method has been renamed to likely_profitable_p and has just a minor rol= e. Now, rule 4) above is something that isn't about profitability, but abo= ut correct behavior, if you propagate mem/v, the code is miscompiled. This particular case has been fixed elsewhere by Haochen in r14-9379. But I think even the 1) and 2) and maybe 3) are a strong don't do it, don't rely solely on rtx costs, increasing the number of loads of the s= ame memory, even when cached, is undesirable, canceling load hoisting can be undesirable as well. So, the following patch restores previous behavior of src contains any MEMs, in that case likely_profitable_p () is taken as the old profitable_p () as a requirement rather than just a hint. For propagation of something which doesn't load from memory this keeps the r14-8319 behavior. 2024-03-09 Jakub Jelinek PR target/114284 * fwprop.cc (try_fwprop_subst_pattern): Don't propagate src containing MEMs unless prop.likely_profitable_p ().=