__vector equality compare: LDC vs {GDC, DMD}
Bruce Carneal
bcarneal at gmail.com
Wed Jul 27 14:40:47 UTC 2022
On Wednesday, 27 July 2022 at 08:04:03 UTC, kinke wrote:
> On Wednesday, 27 July 2022 at 03:50:50 UTC, Bruce Carneal wrote:
>> That said, I am curious: is this behavior intentional or
>> accidental?
>
> Intentional (based on the front-end type of (in)equality and
> identity expressions being a scalar bool, no special case for
> vectors):
> https://github.com/ldc-developers/ldc/commit/db8797e1ced40d555baa3007e6a5f6d05e29b58d
OK. You will be aware of all of these but for future reference
here are six things the compiler could do when presented with a
vector relOp:
1) error out (the current GDC and DMD choice)
2) produce a scalar boolean (the current LDC choice for
eql/not-eql)
3) produce a bit-per-lane reduction to a scalar (as provided by
ballot intrinsics)
4) produce a vector of one byte booleans
5) produce a full lane width vector of "booleans" (with value
zero or one)
6) produce a full lane width vector of masks (all zeros or all
ones)
As noted in the linked to material, 6) is popular. Fortunately 6)
is reliably and efficiently synthesized by LDC and GDC from a
simple known-bounds for loop over a ternary.
More information about the digitalmars-d-ldc
mailing list