Bug 21470 – wrong codegen with core.simd when implementing _mm_set1_epi8

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
All
Creation time
2020-12-11T07:11:11Z
Last change time
2020-12-23T09:27:21Z
Keywords
backend, SIMD
Assigned to
No Owner
Creator
ponce
See also
https://issues.dlang.org/show_bug.cgi?id=21469

Comments

Comment #0 by aliloko — 2020-12-11T07:11:11Z
Probably very similar bug than https://issues.dlang.org/show_bug.cgi?id=21469 but this time it is wrong codegen rather than crashing DMD. HOW TO REPRODUCE Using DMD 2.094.0, build this file with: dmd -m64 test2.d -g ------------ test2.d ------------------- import core.simd; int4 _mm_set1_epi8 (byte a) pure @trusted { return cast(int4)(byte16(a)); } void main(string[] args) { byte16 b = cast(byte16) _mm_set1_epi8(31); for (int i = 0; i < 16; ++i) assert(b.array[i] == 31); // fails } ---------------------------------------- OUTPUT [email protected](13): Assertion failure we can workaround this bug: ----------------------------------------- int4 _mm_set1_epi8 (byte a) pure @trusted { byte16 b = a; // on a separate line return cast(int4)(b); } -----------------------------------------
Comment #1 by aliloko — 2020-12-11T07:25:39Z
Also similarly: int4 _mm_set1_epi64x (long a) pure @trusted { long2 b = a; return cast(int4)(b); } works but: int4 _mm_set1_epi64x (long a) pure @trusted { return cast(int4)(long2(a)); } doesn't and is likely the same bug. Both version work correctly in GDC and LDC.
Comment #2 by bugzilla — 2020-12-23T09:27:21Z
This is indeed the same bug as https://issues.dlang.org/show_bug.cgi?id=21469 *** This issue has been marked as a duplicate of issue 21469 ***