https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98801

--- Comment #7 from Jeff Hurchalla <jeffhurchalla at gmail dot com> ---
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 crypto'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 for
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/12OmNqJZgIG/pdf
)

So I'd limit my request to a conditional move builtin, just motivated by desire
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 passes,
which puts it in the same category as the ternary operator idiom.  Any change
to compiler flags or version means rechecking generated assembly, which is
awkward even the first time.

Reply via email to