Skip to content

Commit 818d715

Browse files
authored
[Analysis] atan2: isTriviallyVectorizable; add to massv and accelerate veclibs (#113637)
This change is part of this proposal: https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294 - Return true for atan2 from isTriviallyVectorizable - Add atan2 to VecFuncs.def for massv and accelerate libraries. - Add atan2 to hasOptimizedCodeGen - Add atan2 support in llvm/lib/Analysis/ValueTracking.cpp llvm::getIntrinsicForCallSite and update vectorization tests - Add atan2 name check to isLoweredToCall in llvm/include/llvm/Analysis/TargetTransformInfoImpl.h - Note: there's no test coverage for these names in isLoweredToCall, except that Transforms/TailCallElim/inf-recursion.ll is impacted by the "fabs" case Thanks to @jroelofs for the atan2 accelerate veclib and associated test additions, plus the hasOptimizedCodeGen addition. Part of: Implement the atan2 HLSL Function #70096.
1 parent ff98efa commit 818d715

File tree

8 files changed

+251
-0
lines changed

8 files changed

+251
-0
lines changed

llvm/include/llvm/Analysis/TargetLibraryInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ class TargetLibraryInfo {
410410
// clang-format off
411411
case LibFunc_acos: case LibFunc_acosf: case LibFunc_acosl:
412412
case LibFunc_asin: case LibFunc_asinf: case LibFunc_asinl:
413+
case LibFunc_atan2: case LibFunc_atan2f: case LibFunc_atan2l:
413414
case LibFunc_atan: case LibFunc_atanf: case LibFunc_atanl:
414415
case LibFunc_ceil: case LibFunc_ceilf: case LibFunc_ceill:
415416
case LibFunc_copysign: case LibFunc_copysignf: case LibFunc_copysignl:

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ class TargetTransformInfoImplBase {
174174
Name == "asin" || Name == "asinf" || Name == "asinl" ||
175175
Name == "acos" || Name == "acosf" || Name == "acosl" ||
176176
Name == "atan" || Name == "atanf" || Name == "atanl" ||
177+
Name == "atan2" || Name == "atan2f" || Name == "atan2l"||
177178
Name == "sinh" || Name == "sinhf" || Name == "sinhl" ||
178179
Name == "cosh" || Name == "coshf" || Name == "coshl" ||
179180
Name == "tanh" || Name == "tanhf" || Name == "tanhl" ||

llvm/include/llvm/Analysis/VecFuncs.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ TLI_DEFINE_VECFUNC("acosf", "vacosf", FIXED(4), "_ZGV_LLVM_N4v")
5656
TLI_DEFINE_VECFUNC("llvm.acos.f32", "vacosf", FIXED(4), "_ZGV_LLVM_N4v")
5757
TLI_DEFINE_VECFUNC("atanf", "vatanf", FIXED(4), "_ZGV_LLVM_N4v")
5858
TLI_DEFINE_VECFUNC("llvm.atan.f32", "vatanf", FIXED(4), "_ZGV_LLVM_N4v")
59+
TLI_DEFINE_VECFUNC("atan2f", "vatan2f", FIXED(4), "_ZGV_LLVM_N4vv")
60+
TLI_DEFINE_VECFUNC("llvm.atan2.f32", "vatan2f", FIXED(4), "_ZGV_LLVM_N4vv")
5961

6062
// Hyperbolic Functions
6163
TLI_DEFINE_VECFUNC("sinhf", "vsinhf", FIXED(4), "_ZGV_LLVM_N4v")
@@ -289,7 +291,9 @@ TLI_DEFINE_VECFUNC("acosf", "__acosf4", FIXED(4), "_ZGV_LLVM_N4v")
289291
TLI_DEFINE_VECFUNC("atan", "__atand2", FIXED(2), "_ZGV_LLVM_N2v")
290292
TLI_DEFINE_VECFUNC("atanf", "__atanf4", FIXED(4), "_ZGV_LLVM_N4v")
291293
TLI_DEFINE_VECFUNC("atan2", "__atan2d2", FIXED(2), "_ZGV_LLVM_N2vv")
294+
TLI_DEFINE_VECFUNC("llvm.atan2.f64", "__atan2d2", FIXED(2), "_ZGV_LLVM_N2vv")
292295
TLI_DEFINE_VECFUNC("atan2f", "__atan2f4", FIXED(4), "_ZGV_LLVM_N4vv")
296+
TLI_DEFINE_VECFUNC("llvm.atan2.f32", "__atan2f4", FIXED(4), "_ZGV_LLVM_N4vv")
293297

294298
// Hyperbolic Functions
295299
TLI_DEFINE_VECFUNC("sinh", "__sinhd2", FIXED(2), "_ZGV_LLVM_N2v")

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4238,6 +4238,10 @@ Intrinsic::ID llvm::getIntrinsicForCallSite(const CallBase &CB,
42384238
case LibFunc_atanf:
42394239
case LibFunc_atanl:
42404240
return Intrinsic::atan;
4241+
case LibFunc_atan2:
4242+
case LibFunc_atan2f:
4243+
case LibFunc_atan2l:
4244+
return Intrinsic::atan2;
42414245
case LibFunc_sinh:
42424246
case LibFunc_sinhf:
42434247
case LibFunc_sinhl:

llvm/lib/Analysis/VectorUtils.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ bool llvm::isTriviallyVectorizable(Intrinsic::ID ID) {
6969
case Intrinsic::asin:
7070
case Intrinsic::acos:
7171
case Intrinsic::atan:
72+
case Intrinsic::atan2:
7273
case Intrinsic::sin:
7374
case Intrinsic::cos:
7475
case Intrinsic::tan:

llvm/test/Transforms/LoopVectorize/PowerPC/massv-calls.ll

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,52 @@ for.end:
12441244
ret void
12451245
}
12461246

1247+
define void @atan2_f64_intrinsic(ptr nocapture %varray) {
1248+
; CHECK-LABEL: @atan2_f64_intrinsic(
1249+
; CHECK: __atan2d2{{.*}}<2 x double>
1250+
; CHECK: ret void
1251+
;
1252+
entry:
1253+
br label %for.body
1254+
1255+
for.body:
1256+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
1257+
%tmp = trunc i64 %iv to i32
1258+
%conv = sitofp i32 %tmp to double
1259+
%call = tail call double @llvm.atan2.f64(double %conv, double %conv)
1260+
%arrayidx = getelementptr inbounds double, ptr %varray, i64 %iv
1261+
store double %call, ptr %arrayidx, align 4
1262+
%iv.next = add nuw nsw i64 %iv, 1
1263+
%exitcond = icmp eq i64 %iv.next, 1000
1264+
br i1 %exitcond, label %for.end, label %for.body
1265+
1266+
for.end:
1267+
ret void
1268+
}
1269+
1270+
define void @atan2_f32_intrinsic(ptr nocapture %varray) {
1271+
; CHECK-LABEL: @atan2_f32_intrinsic(
1272+
; CHECK: __atan2f4{{.*}}<4 x float>
1273+
; CHECK: ret void
1274+
;
1275+
entry:
1276+
br label %for.body
1277+
1278+
for.body:
1279+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
1280+
%tmp = trunc i64 %iv to i32
1281+
%conv = sitofp i32 %tmp to float
1282+
%call = tail call float @llvm.atan2.f32(float %conv, float %conv)
1283+
%arrayidx = getelementptr inbounds float, ptr %varray, i64 %iv
1284+
store float %call, ptr %arrayidx, align 4
1285+
%iv.next = add nuw nsw i64 %iv, 1
1286+
%exitcond = icmp eq i64 %iv.next, 1000
1287+
br i1 %exitcond, label %for.end, label %for.body
1288+
1289+
for.end:
1290+
ret void
1291+
}
1292+
12471293
define void @sinh_f64(ptr nocapture %varray) {
12481294
; CHECK-LABEL: @sinh_f64(
12491295
; CHECK: __sinhd2{{.*}}<2 x double>

llvm/test/Transforms/SLPVectorizer/AArch64/accelerate-vector-functions-inseltpoison.ll

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,103 @@ entry:
801801
%vecins.3 = insertelement <4 x float> %vecins.2, float %4, i32 3
802802
ret <4 x float> %vecins.3
803803
}
804+
declare float @atan2f(float,float) readonly nounwind willreturn
805+
define <4 x float> @atan2_4x(ptr %a, ptr %b) {
806+
; CHECK-LABEL: @atan2_4x(
807+
; CHECK-NEXT: entry:
808+
; CHECK-NEXT: [[TMP0:%.*]] = load <4 x float>, ptr [[A:%.*]], align 16
809+
; CHECK-NEXT: [[BB:%.*]] = load <4 x float>, ptr [[B:%.*]], align 16
810+
; CHECK-NEXT: [[TMP1:%.*]] = call fast <4 x float> @vatan2f(<4 x float> [[TMP0]], <4 x float> [[BB]])
811+
; CHECK-NEXT: ret <4 x float> [[TMP1]]
812+
;
813+
; NOACCELERATE-LABEL: @atan2_4x(
814+
; NOACCELERATE-NEXT: entry:
815+
; NOACCELERATE-NEXT: [[TMP0:%.*]] = load <4 x float>, ptr [[A:%.*]], align 16
816+
; NOACCELERATE-NEXT: [[BB:%.*]] = load <4 x float>, ptr [[B:%.*]], align 16
817+
; NOACCELERATE-NEXT: [[VECEXT:%.*]] = extractelement <4 x float> [[TMP0]], i32 0
818+
; NOACCELERATE-NEXT: [[VECEXTB:%.*]] = extractelement <4 x float> [[BB]], i32 0
819+
; NOACCELERATE-NEXT: [[TMP1:%.*]] = tail call fast float @atan2f(float [[VECEXT]], float [[VECEXTB]])
820+
; NOACCELERATE-NEXT: [[VECINS:%.*]] = insertelement <4 x float> poison, float [[TMP1]], i32 0
821+
; NOACCELERATE-NEXT: [[VECEXT_1:%.*]] = extractelement <4 x float> [[TMP0]], i32 1
822+
; NOACCELERATE-NEXT: [[VECEXTB_1:%.*]] = extractelement <4 x float> [[BB]], i32 1
823+
; NOACCELERATE-NEXT: [[TMP2:%.*]] = tail call fast float @atan2f(float [[VECEXT_1]], float [[VECEXTB_1]])
824+
; NOACCELERATE-NEXT: [[VECINS_1:%.*]] = insertelement <4 x float> [[VECINS]], float [[TMP2]], i32 1
825+
; NOACCELERATE-NEXT: [[TMP3:%.*]] = shufflevector <4 x float> [[TMP0]], <4 x float> poison, <2 x i32> <i32 2, i32 3>
826+
; NOACCELERATE-NEXT: [[TMP4:%.*]] = shufflevector <4 x float> [[BB]], <4 x float> poison, <2 x i32> <i32 2, i32 3>
827+
; NOACCELERATE-NEXT: [[TMP5:%.*]] = call fast <2 x float> @llvm.atan2.v2f32(<2 x float> [[TMP3]], <2 x float> [[TMP4]])
828+
; NOACCELERATE-NEXT: [[TMP6:%.*]] = shufflevector <2 x float> [[TMP5]], <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 poison, i32 poison>
829+
; NOACCELERATE-NEXT: [[VECINS_3:%.*]] = shufflevector <4 x float> [[VECINS_1]], <4 x float> [[TMP6]], <4 x i32> <i32 0, i32 1, i32 4, i32 5>
830+
; NOACCELERATE-NEXT: ret <4 x float> [[VECINS_3]]
831+
;
832+
entry:
833+
%0 = load <4 x float>, ptr %a, align 16
834+
%bb = load <4 x float>, ptr %b, align 16
835+
%vecext = extractelement <4 x float> %0, i32 0
836+
%vecextb = extractelement <4 x float> %bb, i32 0
837+
%1 = tail call fast float @atan2f(float %vecext, float %vecextb)
838+
%vecins = insertelement <4 x float> poison, float %1, i32 0
839+
%vecext.1 = extractelement <4 x float> %0, i32 1
840+
%vecextb.1 = extractelement <4 x float> %bb, i32 1
841+
%2 = tail call fast float @atan2f(float %vecext.1, float %vecextb.1)
842+
%vecins.1 = insertelement <4 x float> %vecins, float %2, i32 1
843+
%vecext.2 = extractelement <4 x float> %0, i32 2
844+
%vecextb.2 = extractelement <4 x float> %bb, i32 2
845+
%3 = tail call fast float @atan2f(float %vecext.2, float %vecextb.2)
846+
%vecins.2 = insertelement <4 x float> %vecins.1, float %3, i32 2
847+
%vecext.3 = extractelement <4 x float> %0, i32 3
848+
%vecextb.3 = extractelement <4 x float> %bb, i32 3
849+
%4 = tail call fast float @atan2f(float %vecext.3, float %vecextb.3)
850+
%vecins.3 = insertelement <4 x float> %vecins.2, float %4, i32 3
851+
ret <4 x float> %vecins.3
852+
}
853+
define <4 x float> @int_atan2_4x(ptr %a, ptr %b) {
854+
; CHECK-LABEL: @int_atan2_4x(
855+
; CHECK-NEXT: entry:
856+
; CHECK-NEXT: [[TMP0:%.*]] = load <4 x float>, ptr [[A:%.*]], align 16
857+
; CHECK-NEXT: [[BB:%.*]] = load <4 x float>, ptr [[B:%.*]], align 16
858+
; CHECK-NEXT: [[TMP1:%.*]] = call fast <4 x float> @vatan2f(<4 x float> [[TMP0]], <4 x float> [[BB]])
859+
; CHECK-NEXT: ret <4 x float> [[TMP1]]
860+
;
861+
; NOACCELERATE-LABEL: @int_atan2_4x(
862+
; NOACCELERATE-NEXT: entry:
863+
; NOACCELERATE-NEXT: [[TMP0:%.*]] = load <4 x float>, ptr [[A:%.*]], align 16
864+
; NOACCELERATE-NEXT: [[BB:%.*]] = load <4 x float>, ptr [[B:%.*]], align 16
865+
; NOACCELERATE-NEXT: [[VECEXT:%.*]] = extractelement <4 x float> [[TMP0]], i32 0
866+
; NOACCELERATE-NEXT: [[VECEXTB:%.*]] = extractelement <4 x float> [[BB]], i32 0
867+
; NOACCELERATE-NEXT: [[TMP1:%.*]] = tail call fast float @llvm.atan2.f32(float [[VECEXT]], float [[VECEXTB]])
868+
; NOACCELERATE-NEXT: [[VECINS:%.*]] = insertelement <4 x float> poison, float [[TMP1]], i32 0
869+
; NOACCELERATE-NEXT: [[VECEXT_1:%.*]] = extractelement <4 x float> [[TMP0]], i32 1
870+
; NOACCELERATE-NEXT: [[VECEXTB_1:%.*]] = extractelement <4 x float> [[BB]], i32 1
871+
; NOACCELERATE-NEXT: [[TMP2:%.*]] = tail call fast float @llvm.atan2.f32(float [[VECEXT_1]], float [[VECEXTB_1]])
872+
; NOACCELERATE-NEXT: [[VECINS_1:%.*]] = insertelement <4 x float> [[VECINS]], float [[TMP2]], i32 1
873+
; NOACCELERATE-NEXT: [[TMP3:%.*]] = shufflevector <4 x float> [[TMP0]], <4 x float> poison, <2 x i32> <i32 2, i32 3>
874+
; NOACCELERATE-NEXT: [[TMP4:%.*]] = shufflevector <4 x float> [[BB]], <4 x float> poison, <2 x i32> <i32 2, i32 3>
875+
; NOACCELERATE-NEXT: [[TMP5:%.*]] = call fast <2 x float> @llvm.atan2.v2f32(<2 x float> [[TMP3]], <2 x float> [[TMP4]])
876+
; NOACCELERATE-NEXT: [[TMP6:%.*]] = shufflevector <2 x float> [[TMP5]], <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 poison, i32 poison>
877+
; NOACCELERATE-NEXT: [[VECINS_31:%.*]] = shufflevector <4 x float> [[VECINS_1]], <4 x float> [[TMP6]], <4 x i32> <i32 0, i32 1, i32 4, i32 5>
878+
; NOACCELERATE-NEXT: ret <4 x float> [[VECINS_31]]
879+
;
880+
entry:
881+
%0 = load <4 x float>, ptr %a, align 16
882+
%bb = load <4 x float>, ptr %b, align 16
883+
%vecext = extractelement <4 x float> %0, i32 0
884+
%vecextb = extractelement <4 x float> %bb, i32 0
885+
%1 = tail call fast float @llvm.atan2.f32(float %vecext, float %vecextb)
886+
%vecins = insertelement <4 x float> poison, float %1, i32 0
887+
%vecext.1 = extractelement <4 x float> %0, i32 1
888+
%vecextb.1 = extractelement <4 x float> %bb, i32 1
889+
%2 = tail call fast float @llvm.atan2.f32(float %vecext.1, float %vecextb.1)
890+
%vecins.1 = insertelement <4 x float> %vecins, float %2, i32 1
891+
%vecext.2 = extractelement <4 x float> %0, i32 2
892+
%vecextb.2 = extractelement <4 x float> %bb, i32 2
893+
%3 = tail call fast float @llvm.atan2.f32(float %vecext.2, float %vecextb.2)
894+
%vecins.2 = insertelement <4 x float> %vecins.1, float %3, i32 2
895+
%vecext.3 = extractelement <4 x float> %0, i32 3
896+
%vecextb.3 = extractelement <4 x float> %bb, i32 3
897+
%4 = tail call fast float @llvm.atan2.f32(float %vecext.3, float %vecextb.3)
898+
%vecins.3 = insertelement <4 x float> %vecins.2, float %4, i32 3
899+
ret <4 x float> %vecins.3
900+
}
804901
declare float @sinhf(float) readonly nounwind willreturn
805902
define <4 x float> @sinh_4x(ptr %a) {
806903
; CHECK-LABEL: @sinh_4x(

llvm/test/Transforms/SLPVectorizer/AArch64/accelerate-vector-functions.ll

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,103 @@ entry:
801801
%vecins.3 = insertelement <4 x float> %vecins.2, float %4, i32 3
802802
ret <4 x float> %vecins.3
803803
}
804+
declare float @atan2f(float,float) readonly nounwind willreturn
805+
define <4 x float> @atan2_4x(ptr %a, ptr %b) {
806+
; CHECK-LABEL: @atan2_4x(
807+
; CHECK-NEXT: entry:
808+
; CHECK-NEXT: [[TMP0:%.*]] = load <4 x float>, ptr [[A:%.*]], align 16
809+
; CHECK-NEXT: [[BB:%.*]] = load <4 x float>, ptr [[B:%.*]], align 16
810+
; CHECK-NEXT: [[TMP1:%.*]] = call fast <4 x float> @vatan2f(<4 x float> [[TMP0]], <4 x float> [[BB]])
811+
; CHECK-NEXT: ret <4 x float> [[TMP1]]
812+
;
813+
; NOACCELERATE-LABEL: @atan2_4x(
814+
; NOACCELERATE-NEXT: entry:
815+
; NOACCELERATE-NEXT: [[TMP0:%.*]] = load <4 x float>, ptr [[A:%.*]], align 16
816+
; NOACCELERATE-NEXT: [[BB:%.*]] = load <4 x float>, ptr [[B:%.*]], align 16
817+
; NOACCELERATE-NEXT: [[VECEXT:%.*]] = extractelement <4 x float> [[TMP0]], i32 0
818+
; NOACCELERATE-NEXT: [[VECEXTB:%.*]] = extractelement <4 x float> [[BB]], i32 0
819+
; NOACCELERATE-NEXT: [[TMP1:%.*]] = tail call fast float @atan2f(float [[VECEXT]], float [[VECEXTB]])
820+
; NOACCELERATE-NEXT: [[VECINS:%.*]] = insertelement <4 x float> undef, float [[TMP1]], i32 0
821+
; NOACCELERATE-NEXT: [[VECEXT_1:%.*]] = extractelement <4 x float> [[TMP0]], i32 1
822+
; NOACCELERATE-NEXT: [[VECEXTB_1:%.*]] = extractelement <4 x float> [[BB]], i32 1
823+
; NOACCELERATE-NEXT: [[TMP2:%.*]] = tail call fast float @atan2f(float [[VECEXT_1]], float [[VECEXTB_1]])
824+
; NOACCELERATE-NEXT: [[VECINS_1:%.*]] = insertelement <4 x float> [[VECINS]], float [[TMP2]], i32 1
825+
; NOACCELERATE-NEXT: [[TMP3:%.*]] = shufflevector <4 x float> [[TMP0]], <4 x float> poison, <2 x i32> <i32 2, i32 3>
826+
; NOACCELERATE-NEXT: [[TMP4:%.*]] = shufflevector <4 x float> [[BB]], <4 x float> poison, <2 x i32> <i32 2, i32 3>
827+
; NOACCELERATE-NEXT: [[TMP5:%.*]] = call fast <2 x float> @llvm.atan2.v2f32(<2 x float> [[TMP3]], <2 x float> [[TMP4]])
828+
; NOACCELERATE-NEXT: [[TMP6:%.*]] = shufflevector <2 x float> [[TMP5]], <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 poison, i32 poison>
829+
; NOACCELERATE-NEXT: [[VECINS_3:%.*]] = shufflevector <4 x float> [[VECINS_1]], <4 x float> [[TMP6]], <4 x i32> <i32 0, i32 1, i32 4, i32 5>
830+
; NOACCELERATE-NEXT: ret <4 x float> [[VECINS_3]]
831+
;
832+
entry:
833+
%0 = load <4 x float>, ptr %a, align 16
834+
%bb = load <4 x float>, ptr %b, align 16
835+
%vecext = extractelement <4 x float> %0, i32 0
836+
%vecextb = extractelement <4 x float> %bb, i32 0
837+
%1 = tail call fast float @atan2f(float %vecext, float %vecextb)
838+
%vecins = insertelement <4 x float> undef, float %1, i32 0
839+
%vecext.1 = extractelement <4 x float> %0, i32 1
840+
%vecextb.1 = extractelement <4 x float> %bb, i32 1
841+
%2 = tail call fast float @atan2f(float %vecext.1, float %vecextb.1)
842+
%vecins.1 = insertelement <4 x float> %vecins, float %2, i32 1
843+
%vecext.2 = extractelement <4 x float> %0, i32 2
844+
%vecextb.2 = extractelement <4 x float> %bb, i32 2
845+
%3 = tail call fast float @atan2f(float %vecext.2, float %vecextb.2)
846+
%vecins.2 = insertelement <4 x float> %vecins.1, float %3, i32 2
847+
%vecext.3 = extractelement <4 x float> %0, i32 3
848+
%vecextb.3 = extractelement <4 x float> %bb, i32 3
849+
%4 = tail call fast float @atan2f(float %vecext.3, float %vecextb.3)
850+
%vecins.3 = insertelement <4 x float> %vecins.2, float %4, i32 3
851+
ret <4 x float> %vecins.3
852+
}
853+
define <4 x float> @int_atan2_4x(ptr %a, ptr %b) {
854+
; CHECK-LABEL: @int_atan2_4x(
855+
; CHECK-NEXT: entry:
856+
; CHECK-NEXT: [[TMP0:%.*]] = load <4 x float>, ptr [[A:%.*]], align 16
857+
; CHECK-NEXT: [[BB:%.*]] = load <4 x float>, ptr [[B:%.*]], align 16
858+
; CHECK-NEXT: [[TMP1:%.*]] = call fast <4 x float> @vatan2f(<4 x float> [[TMP0]], <4 x float> [[BB]])
859+
; CHECK-NEXT: ret <4 x float> [[TMP1]]
860+
;
861+
; NOACCELERATE-LABEL: @int_atan2_4x(
862+
; NOACCELERATE-NEXT: entry:
863+
; NOACCELERATE-NEXT: [[TMP0:%.*]] = load <4 x float>, ptr [[A:%.*]], align 16
864+
; NOACCELERATE-NEXT: [[BB:%.*]] = load <4 x float>, ptr [[B:%.*]], align 16
865+
; NOACCELERATE-NEXT: [[VECEXT:%.*]] = extractelement <4 x float> [[TMP0]], i32 0
866+
; NOACCELERATE-NEXT: [[VECEXTB:%.*]] = extractelement <4 x float> [[BB]], i32 0
867+
; NOACCELERATE-NEXT: [[TMP1:%.*]] = tail call fast float @llvm.atan2.f32(float [[VECEXT]], float [[VECEXTB]])
868+
; NOACCELERATE-NEXT: [[VECINS:%.*]] = insertelement <4 x float> undef, float [[TMP1]], i32 0
869+
; NOACCELERATE-NEXT: [[VECEXT_1:%.*]] = extractelement <4 x float> [[TMP0]], i32 1
870+
; NOACCELERATE-NEXT: [[VECEXTB_1:%.*]] = extractelement <4 x float> [[BB]], i32 1
871+
; NOACCELERATE-NEXT: [[TMP2:%.*]] = tail call fast float @llvm.atan2.f32(float [[VECEXT_1]], float [[VECEXTB_1]])
872+
; NOACCELERATE-NEXT: [[VECINS_1:%.*]] = insertelement <4 x float> [[VECINS]], float [[TMP2]], i32 1
873+
; NOACCELERATE-NEXT: [[TMP3:%.*]] = shufflevector <4 x float> [[TMP0]], <4 x float> poison, <2 x i32> <i32 2, i32 3>
874+
; NOACCELERATE-NEXT: [[TMP4:%.*]] = shufflevector <4 x float> [[BB]], <4 x float> poison, <2 x i32> <i32 2, i32 3>
875+
; NOACCELERATE-NEXT: [[TMP5:%.*]] = call fast <2 x float> @llvm.atan2.v2f32(<2 x float> [[TMP3]], <2 x float> [[TMP4]])
876+
; NOACCELERATE-NEXT: [[TMP6:%.*]] = shufflevector <2 x float> [[TMP5]], <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 poison, i32 poison>
877+
; NOACCELERATE-NEXT: [[VECINS_31:%.*]] = shufflevector <4 x float> [[VECINS_1]], <4 x float> [[TMP6]], <4 x i32> <i32 0, i32 1, i32 4, i32 5>
878+
; NOACCELERATE-NEXT: ret <4 x float> [[VECINS_31]]
879+
;
880+
entry:
881+
%0 = load <4 x float>, ptr %a, align 16
882+
%bb = load <4 x float>, ptr %b, align 16
883+
%vecext = extractelement <4 x float> %0, i32 0
884+
%vecextb = extractelement <4 x float> %bb, i32 0
885+
%1 = tail call fast float @llvm.atan2.f32(float %vecext, float %vecextb)
886+
%vecins = insertelement <4 x float> undef, float %1, i32 0
887+
%vecext.1 = extractelement <4 x float> %0, i32 1
888+
%vecextb.1 = extractelement <4 x float> %bb, i32 1
889+
%2 = tail call fast float @llvm.atan2.f32(float %vecext.1, float %vecextb.1)
890+
%vecins.1 = insertelement <4 x float> %vecins, float %2, i32 1
891+
%vecext.2 = extractelement <4 x float> %0, i32 2
892+
%vecextb.2 = extractelement <4 x float> %bb, i32 2
893+
%3 = tail call fast float @llvm.atan2.f32(float %vecext.2, float %vecextb.2)
894+
%vecins.2 = insertelement <4 x float> %vecins.1, float %3, i32 2
895+
%vecext.3 = extractelement <4 x float> %0, i32 3
896+
%vecextb.3 = extractelement <4 x float> %bb, i32 3
897+
%4 = tail call fast float @llvm.atan2.f32(float %vecext.3, float %vecextb.3)
898+
%vecins.3 = insertelement <4 x float> %vecins.2, float %4, i32 3
899+
ret <4 x float> %vecins.3
900+
}
804901
declare float @sinhf(float) readonly nounwind willreturn
805902
define <4 x float> @sinh_4x(ptr %a) {
806903
; CHECK-LABEL: @sinh_4x(

0 commit comments

Comments
 (0)