Are there best practices regarding how to express saturation arithmetic in
LLVM IR? In particular I want to make sure the IR translates efficiently to
(SSE) vector instructions when executed in a simple loop.
My first thought was to implement this naively by zero extending and
branching on the minimum and maximum values. However, I'm also aware of
branchfree alternatives. Do the current instruction selection algorithms
favor one of these forms over the other? I haven't been able to find any
definitive answers on this after having read [2-5]. Perhaps I'm overlooking
a component of the C++ API that makes this easy?
Thanks in advance!
 Branchfree Saturating Arithmetic