From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E6A6A3858288; Wed, 29 May 2024 10:55:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E6A6A3858288 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1716980130; bh=vDBCp9LHwrp9eH3Hol0P6Qp+v/FyFXuf0nkTviLnV3g=; h=From:To:Subject:Date:In-Reply-To:References:From; b=h29My2niRB1sphrWp82+Ibtik4m59tq70MI5UqpB8R0Bq6y+hwzS4LOj3nSuFM+3S qtAjFH5GFOxga8yFTDm+q28XSh7Tg+cwLfMWrqg8O8JaLxHNDg93ZrJBSfuqDS+5fK BfUSgqYi6RJ6ZnxTX/c6KVohgW97TYMXnXz3Uzss= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/114435] PCOM messes up vectorization some times Date: Wed, 29 May 2024 10:55:30 +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: 14.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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=3D114435 --- Comment #7 from Richard Biener --- Ah, the missed store motion is because of the IS_NAN (k) check which makes the memory accesses only conditional executed and thus possibly trap. We "fix" that only during loop unswitching which hoists the invariant check. But there's no store-motion after unswitching. Removing this check shows we can apply store-motion. /* If it can trap, it must be always executed in LOOP. Readonly memory locations may trap when storing to them, but tree_could_trap_p is a predicate for rvalues, so check that explicitly. */ base =3D get_base_address (ref->mem.ref); if ((tree_could_trap_p (ref->mem.ref) || (DECL_P (base) && TREE_READONLY (base))) /* ??? We can at least use false here, allowing loads? We are forcing conditional stores if the ref is not always stored to later anyway. So this would only guard the load we need to emit. Thus when the ref is not loaded we can elide this completely? */ && !ref_always_accessed_p (loop, ref, true)) return false; as the comment explains we cannot do "conditional" initialization, thus guard the load with the duplicated invariant condition.=