From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1E2083844072; Wed, 27 Jan 2021 05:18:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1E2083844072 From: "jeffhurchalla at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/98801] Request for a conditional move built-in function Date: Wed, 27 Jan 2021 05:18:47 +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: 10.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: jeffhurchalla at gmail dot com 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: 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: Wed, 27 Jan 2021 05:18:48 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98801 --- Comment #7 from Jeff Hurchalla --- It might be good to ignore my suggestion to satisfy security needs - if for= no other reason than I can't speak well to those needs. I get the sense crypt= o's need to avoid optimizations can be complicated, for example https://lists.llvm.org/pipermail/llvm-dev/2019-September/135079.html ( Interestingly, the writer mentioned there exists a non-upstreamed patch f= or clang/llvm that has an intrinsic called __builtin_ct_choose, which provides= a guaranteed constant time conditional select. See https://www.computer.org/csdl/pds/api/csdl/proceedings/download-article/12O= mNqJZgIG/pdf ) So I'd limit my request to a conditional move builtin, just motivated by de= sire for performance in situations where a predicate is unpredictable. FYI, clang's __built_unpredictable seems suitable at first, but it's not as good as it seems. It's a hint that doesn't always survive optimization pas= ses, which puts it in the same category as the ternary operator idiom. Any chan= ge to compiler flags or version means rechecking generated assembly, which is awkward even the first time.=