(j3.2006) BEQ, BNE?

Robert Corbett robert.corbett
Wed Jan 30 00:53:35 EST 2013


On 01/29/13 20:24, Van Snyder wrote:
> On Tue, 2013-01-29 at 19:54 -0800, Robert Corbett wrote:
>> On 01/29/13 18:22, Van Snyder wrote:
>>> We did BLT, BLE, etc., but why not BEQ and BNE?
>>>
>>> One might be tempted to use == and /=, but these are required to fail
>>> for +/- zero on ones-complement and sign-magnitude machines because
>>> Fortran doesn't distinguish +0 from -0 for integers.
>>>
>>> Should we add BEQ and BNE, or suggest that users write something like
>>>
>>>     if ( BLE(I,J) .and. BLE(J,I) ) then ! I and J are equal bit strings
>>>       ....
>>>     end if
>>>
>>> or is there another way to do it that I've overlooked?
>>
>> I prefer
>>
>>
>>         IF ( POPCNT(IEOR(I, J)) .EQ. 0) THEN ! I and J are equal bit strings
>
> Sounds more expensive than BEQ(I,J) would be on architectures that can
> do an unsigned integer compare but don't have a fast POPCNT.

Any optimizing compiler worth being called an optimizing compiler can recognize 
idioms and produce good code for them.

Bob Corbett



More information about the J3 mailing list