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

YACCWVT (yet another compiler crash with vector types) #424

Closed
mleise opened this issue Jul 1, 2013 · 5 comments
Closed

YACCWVT (yet another compiler crash with vector types) #424

mleise opened this issue Jul 1, 2013 · 5 comments
Assignees

Comments

@mleise
Copy link
Contributor

mleise commented Jul 1, 2013

In the following code LDC is special as it is the only compiler of the three that crashed on all variants and even goes into infinite loop, ignoring the assert that stops the others in time. (Upstream report: http://d.puremagic.com/issues/show_bug.cgi?id=10518)

import core.simd;
import std.stdio;

version (DigitalMars) { enum isDMD = true;  enum isGDC = false; enum isLDC = false; }
else version (GNU)    { enum isDMD = false; enum isGDC = true;  enum isLDC = false; }
else version (LDC)    { enum isDMD = false; enum isGDC = false; enum isLDC = true;  }

void main()
{
    static if (!isLDC) {
        // ldc: Error: expression 'cast(immutable(__vector(ubyte[16LU])))cast(ubyte)123u' is not a constant
        static immutable ubyte16 vec1 = 123;
        writeln(vec1.array);
    }

    static if (!isDMD && !isLDC && !isGDC) {
        // dmd: init.c:660: virtual Expression* ArrayInitializer::toExpression(Type*): Assertion `0' failed.
        // gdc: init.c:615: virtual Expression* ArrayInitializer::toExpression(): Assertion `0' failed.
        // ldc: infinite loop
        static immutable ubyte16 vec2 = [123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123];
        writeln(vec2.array);
    }
}

I could define a constant like this: "enum ubyte16 SIMDConstant = value;" and GDC will optimize that case to be as fast as a static variable, but unfortunately in LDC my code becomes 4x slower this way, similar to the negative effects on having a long enum array or string.

@redstar
Copy link
Member

redstar commented Jul 1, 2013

I can confirm the first error (LDC head and LLVM 3.4 trunk).

In the second case the assertion error is triggered for me, too. Do you use an optimized build of ldc?

@mleise
Copy link
Contributor Author

mleise commented Jul 1, 2013

I just use the default build generated by cmake.
But its good to know that in theory it works.

@ghost ghost assigned redstar Jul 3, 2013
@redstar
Copy link
Member

redstar commented Jul 4, 2013

The first error is fixed with commit a2f7246.

redstar added a commit that referenced this issue Jul 7, 2013
redstar added a commit that referenced this issue Aug 17, 2013
redstar added a commit that referenced this issue Jan 3, 2014
This is a backport from DMD 2.065.
redstar added a commit to redstar/ldc that referenced this issue Apr 25, 2014
@redstar
Copy link
Member

redstar commented May 14, 2014

Finally fixed in 0.13.0.

@redstar redstar closed this as completed May 14, 2014
@mleise
Copy link
Contributor Author

mleise commented May 27, 2014

Amen :)

redstar pushed a commit that referenced this issue Sep 27, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants