Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong code for cast static_array->vector #3418

Closed
9il opened this issue May 2, 2020 · 2 comments · Fixed by #3419
Closed

wrong code for cast static_array->vector #3418

9il opened this issue May 2, 2020 · 2 comments · Fixed by #3419

Comments

@9il
Copy link

9il commented May 2, 2020

auto bar3(ref ubyte[64] a, ref ubyte[64] b)
{
    a = (cast(__vector(ubyte[64]))b).array;
}

for -mcpu=haswell

pure nothrow @nogc @safe void example.bar3(ref ubyte[64], ref ubyte[64]):
        vpbroadcastb    ymm0, byte ptr [rdi]
        vmovdqu ymmword ptr [rsi + 32], ymm0
        vmovdqu ymmword ptr [rsi], ymm0
        vzeroupper
        ret

expected

pure nothrow @nogc @safe void example.bar4(ref __vector(ubyte[64]), ref ubyte[64]):
        vmovups ymm0, ymmword ptr [rdi]
        vmovups ymm1, ymmword ptr [rdi + 32]
        vmovups ymmword ptr [rsi + 32], ymm1
        vmovups ymmword ptr [rsi], ymm0
        vzeroupper
        ret

expected is generated from:

auto bar4(ref __vector(ubyte[64]) a, ref ubyte[64] b)
{
    a.array[] = b;
}
@kinke
Copy link
Member

kinke commented May 2, 2020

Thx for the report, that's clearly wrong. - In case this is no toy example and an attempted manual optimization, simply assigning the static array via a = b results in the same expected asm.

@9il
Copy link
Author

9il commented May 10, 2020

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants