-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed
Labels
llvm:SLPVectorizerquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Description
float *f(float *a, float *b, float *c) {
for (int i=0; i<4; i++) {
c[i] = a[i]>b[i]?a[i]:b[i];
}
return c;
}
./bin/clang -O3 --target=x86_64-linux-gnu -mavx2 -S n.c -emit-llvm -ffast-math emits IR like
define dso_local noundef ptr @f(ptr nocapture noundef readonly %a, ptr nocapture noundef readonly %b, ptr noundef returned writeonly %c) local_unnamed_addr #0 {
entry:
%0 = load float, ptr %a, align 4, !tbaa !5
%1 = load float, ptr %b, align 4, !tbaa !5
%. = tail call fast float @llvm.maxnum.f32(float %0, float %1)
store float %., ptr %c, align 4, !tbaa !5
%arrayidx.1 = getelementptr inbounds i8, ptr %a, i64 4
%2 = load float, ptr %arrayidx.1, align 4, !tbaa !5
%arrayidx2.1 = getelementptr inbounds i8, ptr %b, i64 4
%3 = load float, ptr %arrayidx2.1, align 4, !tbaa !5
%..1 = tail call fast float @llvm.maxnum.f32(float %2, float %3)
%arrayidx9.1 = getelementptr inbounds i8, ptr %c, i64 4
store float %..1, ptr %arrayidx9.1, align 4, !tbaa !5
%arrayidx.2 = getelementptr inbounds i8, ptr %a, i64 8
%4 = load float, ptr %arrayidx.2, align 4, !tbaa !5
%arrayidx2.2 = getelementptr inbounds i8, ptr %b, i64 8
%5 = load float, ptr %arrayidx2.2, align 4, !tbaa !5
%..2 = tail call fast float @llvm.maxnum.f32(float %4, float %5)
%arrayidx9.2 = getelementptr inbounds i8, ptr %c, i64 8
store float %..2, ptr %arrayidx9.2, align 4, !tbaa !5
%arrayidx.3 = getelementptr inbounds i8, ptr %a, i64 12
%6 = load float, ptr %arrayidx.3, align 4, !tbaa !5
%arrayidx2.3 = getelementptr inbounds i8, ptr %b, i64 12
%7 = load float, ptr %arrayidx2.3, align 4, !tbaa !5
%..3 = tail call fast float @llvm.maxnum.f32(float %6, float %7)
%arrayidx9.3 = getelementptr inbounds i8, ptr %c, i64 12
store float %..3, ptr %arrayidx9.3, align 4, !tbaa !5
ret ptr %c
}
The pair of [‘llvm.vp.fcmp.*’](https://llvm.org/docs/LangRef.html#id2420) and [‘llvm.vp.select.*’](https://llvm.org/docs/LangRef.html#id2349) may be better.
Metadata
Metadata
Assignees
Labels
llvm:SLPVectorizerquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!