Reputation: 1858
I am trying to get some good codegen for a Rust binary in x64 but it seems very hard to get simd operations for exp
.
I have a simplified code example: https://godbolt.org/z/4MY34T1zj
The code should be easy to vectorize but I get scalar calls to glibc exp.
I can't show with godbold, but the same happens when I use rust libm
and also link time optimizations.
What are the strategies to get vectorized codegen for floating point functions like exp
, log
, etc?
Edit: The LLVM-IR looks to me (who cannot really read llvm-ir) like it has all it needs to vectorize:
vector.body:
%index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%0 = getelementptr inbounds [0 x double], ptr %x.0, i64 0, i64 %index
%wide.load = load <4 x double>, ptr %0, align 8
%1 = tail call <4 x double> @llvm.exp.v4f64(<4 x double> %wide.load)
store <4 x double> %1, ptr %0, align 8
%index.next = add nuw i64 %index, 4
%2 = icmp eq i64 %index.next, %n.vec
br i1 %2, label %middle.block, label %vector.body
So it seems to be a limitation of llvm
This seems relevant: https://reviews.llvm.org/D95373
Upvotes: 1
Views: 83