From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 340C73858D1E; Fri, 2 Sep 2022 07:18:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 340C73858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662103086; bh=CC44raQAhxLHRo/MAfUcb7TDkkbee4g2zxvJPhGZRCc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XwhcyPI7X5FkcAM/ZxK38Sj9ngW9YAbqC9/WHWkKDYQ+qAZLdC5cvMLB75Gt7Wtj0 nC/2IYy40vgEX8DHuClFIP7EL6kLuL+MUzR87TbmkC9lCOAbSa5iLBojt9jU+PFQD+ Nbfa59KZJ66FQ9Cjz6ydw+/QlG0QC+3JS04TrQp8= From: "amonakov at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/106804] Poor codegen for selecting and incrementing value behind a reference Date: Fri, 02 Sep 2022 07:18:05 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: amonakov at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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: cc 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=3D106804 Alexander Monakov changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |amonakov at gcc dot gnu.org --- Comment #8 from Alexander Monakov --- (In reply to Richard Biener from comment #7) > In fact I'd say the reverse transformation is more profitable? In the end it depends on the context. It's a trade-off between a conditional branch and extra data dependencies feeding into the address of a store. If a branch is perfectly predictable, it's preferable. Otherwise, if there's no memory dependency via the store, you don't care about delaying it, making t= he branchless version preferable if that reduces pipeline flushes. If there is= a dependency, it comes down to how often the branch mispredicts, I guess. ________________________________ / \ | People who tinker with compilers | | need __builtin_branchless_select | \ / =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D \ \ \ .--. |o_o | | ~ | // \ \ (| | ) /'\_ _/`\ \___)=3D(___/=