there's been some forward movement on doing this via an appropriate intrinsic in LLVM

https://github.com/llvm/llvm-project/pull/166702

note that this isn't the only "trick" needed for constant-time programming though. Indexing an array with a secret index needs its own trick, for example.

I agree that trying to trick the compiler is very ugly. A well-known applied cryptographer has a paper from last year saying that not only is it ugly, but it doesn't work particularly well, and if anything the trendline of the various "tricks" is that they get less effective over time.

https://eprint.iacr.org/2025/435