[Issue 7953] DMD Error: variable r used before set when compiling with -O

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jan 22 18:55:10 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=7953


kekeniro2 at yahoo.co.jp changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |SIMD
                 CC|                            |kekeniro2 at yahoo.co.jp


--- Comment #5 from kekeniro2 at yahoo.co.jp 2014-01-22 18:54:54 PST ---
(In reply to comment #0)
> When compiling this code with dmd -O it says:
> test.d(55) Error: variable r used before set
> i might have overlooked something, but shouldn't that compile?

I tried to test on Windows.
I suppose this is an _expected_ behavior.
Maybe, 'r.ptr[4]' and its followings lines should be 'r.ptr[0]' and so on.

Please help, SIMD expert... :)

==================================================================
Reduced Code:
//DMDFLAGS=-O -m64
import core.simd;

alias float[8] F8;
F8 simdAdd(F8 a1, F8 a2) {
    F8 res;
    float4 v1;
    float4 v2;
    float4 r;

    // 0..4 OK
    v1.array = a1[0..4];
    v2.array = a2[0..4];
    r = __simd(XMM.ADDPS, v1,v2);
    res.ptr[0] = r.ptr[0];
    res.ptr[1] = r.ptr[1];
    res.ptr[2] = r.ptr[2];
    res.ptr[3] = r.ptr[3];

    // 4..8 NG
    v1.array = a1[4..8];
    v2.array = a2[4..8];
    r = __simd(XMM.ADDPS, v1,v2);
    res.ptr[4] = r.ptr[4]; // Error: variable r used before set
    res.ptr[5] = r.ptr[5];
    res.ptr[6] = r.ptr[6];
    res.ptr[7] = r.ptr[7];

    return res;
}

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


More information about the Digitalmars-d-bugs mailing list