[llvm] [X86] Faster truncf and roundf on x86 SSE2 (PR #226513)

via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 26 17:24:17 PDT 2026


lntue wrote:

> Hi! Thank you both for working on this. I made the issue and would like to join the discussion here :)
> 
> > Also for float, a better bound is `|x| >= 2^23`, and for double, `|x| >= 2^53`.
> 
> I talked about this in the issue. Any value between 2^23 and 2^31 (inclusive) works as a threshold for float32 (similar for float64). I suggested using a large threshold purely in hopes that it helps LLVM to remove the return-unchanged branch if it knows something about the range of the input. I.e. if it knows that the input is between 0 and 2^16, LLVM can remove the branch. So I would like to suggest using 2^31 and 2^63 again, as they may enable more optimizations down the line.
> 
> Frankly, it's probably not going to make much of a huge difference, but having more optimization potential by picking a larger threshold seems like a no-brainer to me.

Is there any mechanism to tell clang what you said in your comments?  Like here is a generic place-holder constant between 2^23 and 2^31, and if clang can compute and show that either max_abs(input) < 2^31 or min_abs(input) >= 2^23, then remove one of the branches.  Otherwise just put any constant between 2^23 and 2^31 there.

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


More information about the llvm-commits mailing list