[Issue 7509] Allow SIMD variable contents to have all their values changed to a single float variable

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Apr 9 03:45:16 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=7509



--- Comment #6 from Manu <turkeyman at gmail.com> 2013-04-09 03:45:14 PDT ---
(In reply to comment #5)
> Actually GDC and LDC are capable of generating optimal code for scalar to
> vector assignment.

It's not a portable concept. It's an operation that should generally be
avoided/discouraged.
I'd rather supply an explicit function like "v = loadScalar(s);", which is
documented with its performance characteristics, and is completely clear to the
programmer that they're using it.
If programmers think v = s; is a benign operation, they'll merrily write bad
code.

> auto foo(float a)
> {
>     __vector(float[4]) va = void;
>     va = 2 * a;
>     return va;
> }
> 
> > I think this should be prohibited at all costs.
> 
> It's not helpful that dmd currently disallows this assignment
> because it promotes usage of 'vec.array = val' which uses the stack.
> Of course one could write a library wrapper but isn't it much
> better to leave this to the compiler?

If I had my way, .array would be removed ;)
Interacting vectors/scalars should be a deliberate and conservative operation.
It's very expensive on most architectures. Used within a tight SIMD loop, it
will ruin your code.

I probably won't win this argument though... people like to be able to write
slow code conveniently ;)
It's not the worst thing in the world, but it's a slippery slope.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list