Skip to content

Commit 9464069

Browse files
eschnettvtjnash
authored andcommitted
jl_special_vector_alignment: Remove work-around for old LLVM version (<=3.8) (#34490)
LLVM <= 3.8 segfaults when LLVM SIMD vectors are not powers of 2 (or a sum of 2 different powers of 2). This LLVM bug was corrected in 2017 (see <https://bugs.llvm.org/show_bug.cgi?id=27708>). This change removes this work-around, finally allowing arbitrary SIMD vector lengths in Julia. This changes Julia's ABI for SIMD types. All SIMD types are now represented as SIMD vectors in LLVM. The work-around represented some SIMD types as LLVM arrays instead to avoid the LLVM segfault. I don't think that SIMD vector lengths that are not a power of 2 were in widespread use, if at all.
1 parent e753b3e commit 9464069

File tree

2 files changed

+0
-18
lines changed

2 files changed

+0
-18
lines changed

src/datatype.c

-12
Original file line numberDiff line numberDiff line change
@@ -191,18 +191,6 @@ unsigned jl_special_vector_alignment(size_t nfields, jl_value_t *t)
191191
{
192192
if (!jl_is_vecelement_type(t))
193193
return 0;
194-
// LLVM 3.7 and 3.8 either crash or generate wrong code for many
195-
// SIMD vector sizes N. It seems the rule is that N can have at
196-
// most 2 non-zero bits. (This is true at least for N<=100.) See
197-
// also <https://llvm.org/bugs/show_bug.cgi?id=27708>.
198-
size_t mask = nfields;
199-
// See e.g.
200-
// <https://graphics.stanford.edu/%7Eseander/bithacks.html> for an
201-
// explanation of this bit-counting algorithm.
202-
mask &= mask-1; // clear least-significant 1 if present
203-
mask &= mask-1; // clear another 1
204-
if (mask)
205-
return 0; // nfields has more than two 1s
206194
assert(jl_datatype_nfields(t)==1);
207195
jl_value_t *ty = jl_field_type((jl_datatype_t*)t, 0);
208196
if (!jl_is_primitivetype(ty))

test/vecelement.jl

-6
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,6 @@ end
105105
# Test various SIMD Vectors with known good sizes
106106
for T in (Float64, Float32, Int64, Int32)
107107
for N in 1:36
108-
# For some vectortypes Julia emits llvm arrays instead of vectors
109-
if N % 7 == 0 || N % 11 == 0 || N % 13 == 0 || N % 15 == 0 ||
110-
N % 19 == 0 || N % 23 == 0 || N % 25 == 0 || N % 27 == 0 ||
111-
N % 29 == 0 || N % 31 == 0
112-
continue
113-
end
114108
a = ntuple(i->VecElement(T(i)), N)
115109
result = ntuple(i-> VecElement(T(i+i)), N)
116110
b = vecadd(a, a)

0 commit comments

Comments
 (0)