Fix Issue 19204 - hashOf doesn't accept SIMD vectors #2289
Conversation
Thanks for your pull request, @n8sh! Bugzilla references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + druntime#2289" |
0a676a1
to
0d43981
Compare
bc15a0a
to
82e0c70
Compare
In trying to get CTFE to work ran into https://issues.dlang.org/show_bug.cgi?id=19223. EDIT: Made a separate bug report https://issues.dlang.org/show_bug.cgi?id=19224 solely for the CTFE failure since it might not have the same cause. |
d87df32
to
cc423f8
Compare
This needs to be merged before dlang/dmd#8676 can be merged, or else any program that has a struct that has a vector field and for any reason needs to generate |
8aac7c3
to
4f265e1
Compare
76a407b
to
53fdaf8
Compare
CTFE now works for float vectors. |
53fdaf8
to
4027713
Compare
test/hash/src/test_hash.d
Outdated
static if (is(simd.float4)) // __traits(isArithmetic) and __traits(isFloating) | ||
{{ | ||
enum simd.float4 val = [1.1f, 2.2f, 3.3f, 4.4f]; | ||
enum ctfeHash = hashOf!(simd.float4)(val); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to explicitly instantiate hashOf
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't need to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I did need to. It was long enough ago that I forgot. Without the explicit instantiation the type is inferred as a floating point array.
src/core/internal/hash.d
Outdated
size_t result = seed; | ||
foreach (x; val.array) | ||
result = hashOf(x, result); | ||
return result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not keep only the CTFE version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It (EDIT: the non-CTFE version) seemed to produce better code with DMD. It looks like LDC2 compiles them both the same though.
3053fcb
to
af56c45
Compare
The explicit instantiation in the CTFE test was needed because at compile time the type was inferred as |
af56c45
to
9b293c9
Compare
No description provided.