Re: What pattern should I use to get a CMOV?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 11/14/2015 5:27 AM, Jeffrey Walton wrote:
> I'm trying to ensure I get a conditional move if its available during
> a saturating subtract operation. The saturating subtract clamps the
> min value at 0.
>
> Here's what it looks like in high level code:
>
>    // Perform a-b, clamp at 0
>     return (a > b) ? (a - b) : 0;
>
> But based on this bug report:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22568, I can't tell if
> that's what I should be using.
>
> What pattern should I use to get a CMOV?
>
> Thanks in advance.
Under what I am guessing may be similar but not identical circumstances,
I would expect better results with
fmaxf(a - b,0.f), if it is possible to set -ffast-math.
gfortran apparently has specific support in i386.md for optimization of
max(a-b,0.) but it doesn't extend to g++ std::max() (as it does in
icc).  I'm not certain whether integer data types are treated symmetrically.
Sorry if I've taken this too far afield into my personal gripes, but I'm
not sure whether you have given enough clues to guess your target in
terms of instruction set, data type, and admissible compile flags.

-- 
Tim Prince




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux