This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: What pattern should I use to get a CMOV?
- From: Mathieu Malaterre <mathieu dot malaterre at gmail dot com>
- To: noloader at gmail dot com
- Cc: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
- Date: Mon, 16 Nov 2015 09:16:11 +0100
- Subject: Re: What pattern should I use to get a CMOV?
- Authentication-results: sourceware.org; auth=none
- References: <CAH8yC8ntZ9L6YAptu=mftX+a5NHFTC8KSjYuYm16sg4biwZmMg at mail dot gmail dot com> <CAF1jjLsJKvcyQATO0ULWcpYbW5PWDp_Q14ZB0QJM+hehwya+Aw at mail dot gmail dot com>
On Sat, Nov 14, 2015 at 5:04 PM, NightStrike <nightstrike@gmail.com> wrote:
> On 11/14/15, Jeffrey Walton <noloader@gmail.com> 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.
>
> This should help.
>
> https://gcc.gnu.org/ml/gcc-help/2014-10/msg00112.html
>
> And look apt halfway down here at the answer from Jorge:
>
> http://stackoverflow.com/questions/427477/fastest-way-to-clamp-a-real-fixed-floating-point-value
Direct link:
http://stackoverflow.com/a/16659263/136285
--
Mathieu