Bug 10905 – [ICE](ctfeexpr.c line 355) with ulong2 in structs

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2013-08-26T15:04:00Z
Last change time
2013-12-10T04:53:50Z
Keywords
CTFE, ice
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2013-08-26T15:04:12Z
import core.simd: ulong2; struct Foo { enum ulong2 y = 1; } struct Bar { ulong2 x; bool spam() const { return x == Foo.y; } } void main() {} DMD 2.064alpha gives: test.d(3): Error: Internal Compiler Error: CTFE literal cast(__vector(ulong[2u]))1LU Assertion failure: '0' on line 355 in file 'ctfeexpr.c'
Comment #1 by ibuclaw — 2013-12-08T04:54:48Z
Comment #2 by bugzilla — 2013-12-08T21:21:28Z
Why does this say x86 on Windows for the platform? x86 on Windows doesn't support SIMD at all.
Comment #3 by github-bugzilla — 2013-12-08T22:50:25Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/74dbc6e48b5e3da2944438804d5cdd055f6fb129 Issue 10905 - [CTFE] Fix [ICE](ctfeexpr.c line 355) with ulong2 in structs https://github.com/D-Programming-Language/dmd/commit/99ff22023fcaf7de49a71bd2e1691523943b8fd5 Merge pull request #2937 from ibuclaw/issue10905 Issue 10905 - [CTFE] Fix [ICE](ctfeexpr.c line 355) with ulong2 in structs
Comment #4 by ibuclaw — 2013-12-09T01:40:19Z
Comment #5 by ibuclaw — 2013-12-09T01:41:04Z
I guess x86 Windows is bearophile's platform of choice, and that's the compiler he used when he found the bug.
Comment #6 by bearophile_hugs — 2013-12-09T03:00:11Z
The ICE is fixex, but this code gives: import core.simd: ulong2; void main() { ulong2 x; immutable ulong2 y; bool b = x == y; } temp.d(5): Error: incompatible types for ((cast(const(__vector(ulong[2])))x) == (cast(const(__vector(ulong[2])))y)): 'const(__vector(ulong[2]))' and 'const(__vector(ulong[2]))'
Comment #7 by ibuclaw — 2013-12-09T03:11:48Z
See the testcase in the pull request. Currently the frontend explicitly disallows comparing vectors using == expression. This seems like an odd limitation to me, but I'm not arguing it. Please raise a new pull request if you wish to change the language behaviour. Regards Iain
Comment #8 by ibuclaw — 2013-12-09T03:12:36Z
Err... I mean please raise a new bug report.
Comment #9 by ibuclaw — 2013-12-10T02:01:53Z
One thing to note is that the result of a vector == comparison would not be a boolean. import core.simd; int4 a = [1,2,3,4]; int4 b = [3,2,1,4]; if (a == b) { } // Error: vector comparison returning a boolean. int4 c = (a == b); assert(c.array = [0, -1, 0, -1]);
Comment #10 by bearophile_hugs — 2013-12-10T04:53:50Z
(In reply to comment #9) > One thing to note is that the result of a vector == comparison would not be a > boolean. > > import core.simd; > > int4 a = [1,2,3,4]; > int4 b = [3,2,1,4]; > > if (a == b) { } // Error: vector comparison returning a boolean. > > int4 c = (a == b); > assert(c.array = [0, -1, 0, -1]); That seems acceptable. But Manu is much more expert than me on such matters, so we should listen to his opinion on this. A possible semantics for: if (a == b) {} else {} Is to run the first branch if all items are equal ([-1, -1, -1, -1]) and the second branch otherwise. I am not sure but I think some kind of Intel compiler works like this.