Jump to page: 1 2
Thread overview
[Issue 7413] New: Vector literals don't work
Jan 31, 2012
Manu
Feb 01, 2012
Manu
Mar 01, 2012
Manu
Mar 01, 2012
Sean Cavanaugh
Mar 11, 2012
Manu
Mar 11, 2012
Manu
Apr 21, 2012
SomeDude
May 01, 2012
Manu
May 01, 2012
Walter Bright
May 01, 2012
Manu
May 02, 2012
Walter Bright
May 02, 2012
Manu
May 02, 2012
Don
May 02, 2012
Manu
May 02, 2012
Don
May 03, 2012
Manu
January 31, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7413

           Summary: Vector literals don't work
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: turkeyman@gmail.com


--- Comment #0 from Manu <turkeyman@gmail.com> 2012-01-31 10:54:16 PST ---
Vector literals in the form:
  float4 v = [1,2,3,4];

still don't appear to work...

Literal should be allocated & aligned, ideally PC relative, right next to the
function (at least possible in x64).
Additionally, assigning literals '0' or [0,0,0,0] should generate the
appropriate xor opcode.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 01, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7413



--- Comment #1 from Manu <turkeyman@gmail.com> 2012-01-31 17:27:58 PST ---
There's a bunch of other handy immediates too:

-1 = cmpeq(anyReg, anyReg)
 - 1 opcode, always better than a load

1,3,7,15,etc can be generated by shifting -1 right by some immediate
 - 2 opcodes, pc-relative load might be better, depends on pipeline

2,4,8,16,etc can be generated by shifting 1 left
 - 3 opcodes, pc-relative load is probably better, depends on pipeline

1.0f (0x3f800000) can be generated by shifting -1 right 25 bits, then left 23
bits
 - 3 opcodes, pc-relative load is probably better, depends on pipeline

etc...

Just something to be aware of

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 01, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7413



--- Comment #2 from Manu <turkeyman@gmail.com> 2012-03-01 13:53:30 PST ---
I'd like to see this promoted above the priority of other SIMD tasks. This is holding me up. I can't write unit tests without literals.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 01, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7413


Sean Cavanaugh <WorksOnMyMachine@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |WorksOnMyMachine@gmail.com


--- Comment #3 from Sean Cavanaugh <WorksOnMyMachine@gmail.com> 2012-03-01 14:16:27 PST ---
Hex float constants don't seem to be expressive enough to handle all 2^32 or 2^64 bit patterns for float or double (nan, exponent masks, mantissa only masks etc).

This is a problem for defining more exotic data while maintining the correct 'type' for the constant (float4 instead of an int4, double2 instead of long2 etc)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 11, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7413


Manu <turkeyman@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |blocker


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 11, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7413



--- Comment #4 from Manu <turkeyman@gmail.com> 2012-03-11 12:11:46 PDT ---
Walter had planned to use standard array literal syntax as far as I knew:
float4 v = [1.0, 2.0, 3.0, 4.0];
shourt8 sv = [1,2,3,4,5,6,7,8];

How he intended to disambiguate the type, I have no idea.
Vector literals must be 128bit aligned, so the compiler needs to recognise
they're being assigned to a vector and treat them special.
It sounds better to have an explicit literal syntax to me.

I guess there's always this option, but it's horrible:
int4 v = __vector([1,2,3,4]);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 21, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7413


SomeDude <lovelydear@mailmetrash.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lovelydear@mailmetrash.com


--- Comment #5 from SomeDude <lovelydear@mailmetrash.com> 2012-04-21 05:35:44 PDT ---
See also issue 7414

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 01, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7413



--- Comment #7 from Manu <turkeyman@gmail.com> 2012-05-01 07:44:29 PDT ---
(In reply to comment #6)
> Note that for the moment you can do things like:
> 
>     int[4] o = [1,2,3,4];
>     int4 v1;
>     v1.array = o;

Indeed, but that's not something you can just type conveniently in user code. I wrap that in a little constructor function, which is fine for now.

Proper literals are blocking std.simd though (which I'd really like to finish). I don't think it's fair to say it's done without literals, and unit tests which need an awful lot of literals.

If it's not likely to make the short list though, I'll finish it off with some sort of constructor function in the mean time.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 01, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7413



--- Comment #8 from Walter Bright <bugzilla@digitalmars.com> 2012-05-01 10:40:39 PDT ---
I'm looking in to it, I just thought that the workaround could keep you going for the moment.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 01, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7413



--- Comment #9 from Manu <turkeyman@gmail.com> 2012-05-01 10:51:12 PDT ---
(In reply to comment #8)
> I'm looking in to it, I just thought that the workaround could keep you going for the moment.

Yeah, no worries. Already on it. Cheers :)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
« First   ‹ Prev
1 2