# SIMD struggles, seeking solutions (with KangarooTwelve.jl)

**URL:** https://discourse.julialang.org/t/simd-struggles-seeking-solutions-with-kangarootwelve-jl/105800
**Category:** Performance
**Created:** [November 4, 2023, 7:40pm UTC](https://discourse.julialang.org/t/simd-struggles-seeking-solutions-with-kangarootwelve-jl/105800 "2023-11-04T19:40:11Z")
**Posts on this page:** 4
**Page:** 2

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [November 7, 2023, 9:36am UTC](https://discourse.julialang.org/t/simd-struggles-seeking-solutions-with-kangarootwelve-jl/105800/21 "2023-11-07T09:36:20Z")

</div>

> [@Zentrik](#):
>
> EDIT: wrong function, we’re probably calling `lshr_int` but still shows that this probably should have been checked for.

SIMD.jl has some checks that are supposed to fix the undefined behavior:

> <https://github.com/eschnett/SIMD.jl/blob/0334b82341981a72821d3268cfe079ac0843e6ac/src/simdvec.jl#L319-L339C4>

But perhaps it is buggy?

---

<div class="post-metadata">

### Author: ![tecosaur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tecosaur/32/23206_2.png) [@tecosaur](https://discourse.julialang.org/u/tecosaur)
#### Post date: [November 7, 2023, 10:21am UTC](https://discourse.julialang.org/t/simd-struggles-seeking-solutions-with-kangarootwelve-jl/105800/22 "2023-11-07T10:21:12Z")

</div>

That’s interesting Julius. Thanks for that analysis.

I might consider that hacky approach in future, though I’m also interested to see if [https://github.com/JuliaLang/julia/pull/44186](https://github.com/JuliaLang/julia/pull/44186) (kindly pointed out to me by Sukera) might remove the overhead that’s being such a pain here?

---

<div class="post-metadata">

### Author: ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)
#### Post date: [November 7, 2023, 10:32am UTC](https://discourse.julialang.org/t/simd-struggles-seeking-solutions-with-kangarootwelve-jl/105800/23 "2023-11-07T10:32:01Z")

</div>

> [@kristoffer.carlsson](#):
>
> But perhaps it is buggy?

Likely! Shouldn’t these be `y >= sizeof(T1)*8`?

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [November 7, 2023, 11:38am UTC](https://discourse.julialang.org/t/simd-struggles-seeking-solutions-with-kangarootwelve-jl/105800/24 "2023-11-07T11:38:11Z")

</div>

Indeed, [fix some shift operations to agree with Base (and prevent undefined behavior) by KristofferC · Pull Request #119 · eschnett/SIMD.jl · GitHub](https://github.com/eschnett/SIMD.jl/pull/119) should fix that I think

[Previous page](https://discourse.julialang.org/t/simd-struggles-seeking-solutions-with-kangarootwelve-jl/105800.md?page=1)
