Skip to content

Commit f2f4127

Browse files
committed
add LoopVectorize support for arc and hyperbolic trig intrinsics
1 parent 3611871 commit f2f4127

File tree

2 files changed

+157
-0
lines changed

2 files changed

+157
-0
lines changed

llvm/include/llvm/Analysis/VecFuncs.def

+6
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,19 @@ TLI_DEFINE_VECFUNC("llvm.cos.f32", "vcosf", FIXED(4), "_ZGV_LLVM_N4v")
5151
TLI_DEFINE_VECFUNC("tanf", "vtanf", FIXED(4), "_ZGV_LLVM_N4v")
5252
TLI_DEFINE_VECFUNC("llvm.tan.f32", "vtanf", FIXED(4), "_ZGV_LLVM_N4v")
5353
TLI_DEFINE_VECFUNC("asinf", "vasinf", FIXED(4), "_ZGV_LLVM_N4v")
54+
TLI_DEFINE_VECFUNC("llvm.asin.f32", "vasinf", FIXED(4), "_ZGV_LLVM_N4v")
5455
TLI_DEFINE_VECFUNC("acosf", "vacosf", FIXED(4), "_ZGV_LLVM_N4v")
56+
TLI_DEFINE_VECFUNC("llvm.acos.f32", "vacosf", FIXED(4), "_ZGV_LLVM_N4v")
5557
TLI_DEFINE_VECFUNC("atanf", "vatanf", FIXED(4), "_ZGV_LLVM_N4v")
58+
TLI_DEFINE_VECFUNC("llvm.atan.f32", "vatanf", FIXED(4), "_ZGV_LLVM_N4v")
5659

5760
// Hyperbolic Functions
5861
TLI_DEFINE_VECFUNC("sinhf", "vsinhf", FIXED(4), "_ZGV_LLVM_N4v")
62+
TLI_DEFINE_VECFUNC("llvm.sinh.f32", "vsinhf", FIXED(4), "_ZGV_LLVM_N4v")
5963
TLI_DEFINE_VECFUNC("coshf", "vcoshf", FIXED(4), "_ZGV_LLVM_N4v")
64+
TLI_DEFINE_VECFUNC("llvm.cosh.f32", "vcoshf", FIXED(4), "_ZGV_LLVM_N4v")
6065
TLI_DEFINE_VECFUNC("tanhf", "vtanhf", FIXED(4), "_ZGV_LLVM_N4v")
66+
TLI_DEFINE_VECFUNC("llvm.tanh.f32", "vtanhf", FIXED(4), "_ZGV_LLVM_N4v")
6167
TLI_DEFINE_VECFUNC("asinhf", "vasinhf", FIXED(4), "_ZGV_LLVM_N4v")
6268
TLI_DEFINE_VECFUNC("acoshf", "vacoshf", FIXED(4), "_ZGV_LLVM_N4v")
6369
TLI_DEFINE_VECFUNC("atanhf", "vatanhf", FIXED(4), "_ZGV_LLVM_N4v")

llvm/test/Transforms/LoopVectorize/X86/veclib-calls.ll

+151
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ for.end: ; preds = %for.body, %entry
431431
ret void
432432
}
433433

434+
434435
;CHECK-LABEL: @asin_f32(
435436
;CHECK: vasinf{{.*}}<4 x float>
436437
;CHECK: ret void
@@ -456,6 +457,31 @@ for.end: ; preds = %for.body, %entry
456457
ret void
457458
}
458459

460+
;CHECK-LABEL: @asin_f32_intrinsic(
461+
;CHECK: vasinf{{.*}}<4 x float>
462+
;CHECK: ret void
463+
declare float @llvm.asin.f32(float) nounwind readnone
464+
define void @asin_f32_intrinsic(i32 %n, ptr noalias %y, ptr noalias %x) nounwind uwtable {
465+
entry:
466+
%cmp6 = icmp sgt i32 %n, 0
467+
br i1 %cmp6, label %for.body, label %for.end
468+
469+
for.body: ; preds = %entry, %for.body
470+
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
471+
%arrayidx = getelementptr inbounds float, ptr %y, i64 %indvars.iv
472+
%0 = load float, ptr %arrayidx, align 4
473+
%call = tail call float @llvm.asin.f32(float %0) nounwind readnone
474+
%arrayidx2 = getelementptr inbounds float, ptr %x, i64 %indvars.iv
475+
store float %call, ptr %arrayidx2, align 4
476+
%indvars.iv.next = add i64 %indvars.iv, 1
477+
%lftr.wideiv = trunc i64 %indvars.iv.next to i32
478+
%exitcond = icmp eq i32 %lftr.wideiv, %n
479+
br i1 %exitcond, label %for.end, label %for.body
480+
481+
for.end: ; preds = %for.body, %entry
482+
ret void
483+
}
484+
459485
;CHECK-LABEL: @acos_f32(
460486
;CHECK: vacosf{{.*}}<4 x float>
461487
;CHECK: ret void
@@ -481,6 +507,31 @@ for.end: ; preds = %for.body, %entry
481507
ret void
482508
}
483509

510+
;CHECK-LABEL: @acos_f32_intrinsic(
511+
;CHECK: vacosf{{.*}}<4 x float>
512+
;CHECK: ret void
513+
declare float @llvm.acos.f32(float) nounwind readnone
514+
define void @acos_f32_intrinsic(i32 %n, ptr noalias %y, ptr noalias %x) nounwind uwtable {
515+
entry:
516+
%cmp6 = icmp sgt i32 %n, 0
517+
br i1 %cmp6, label %for.body, label %for.end
518+
519+
for.body: ; preds = %entry, %for.body
520+
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
521+
%arrayidx = getelementptr inbounds float, ptr %y, i64 %indvars.iv
522+
%0 = load float, ptr %arrayidx, align 4
523+
%call = tail call float @llvm.acos.f32(float %0) nounwind readnone
524+
%arrayidx2 = getelementptr inbounds float, ptr %x, i64 %indvars.iv
525+
store float %call, ptr %arrayidx2, align 4
526+
%indvars.iv.next = add i64 %indvars.iv, 1
527+
%lftr.wideiv = trunc i64 %indvars.iv.next to i32
528+
%exitcond = icmp eq i32 %lftr.wideiv, %n
529+
br i1 %exitcond, label %for.end, label %for.body
530+
531+
for.end: ; preds = %for.body, %entry
532+
ret void
533+
}
534+
484535
;CHECK-LABEL: @atan_f32(
485536
;CHECK: vatanf{{.*}}<4 x float>
486537
;CHECK: ret void
@@ -506,6 +557,31 @@ for.end: ; preds = %for.body, %entry
506557
ret void
507558
}
508559

560+
;CHECK-LABEL: @atan_f32_intrinsic(
561+
;CHECK: vatanf{{.*}}<4 x float>
562+
;CHECK: ret void
563+
declare float @llvm.atan.f32(float) nounwind readnone
564+
define void @atan_f32_intrinsic(i32 %n, ptr noalias %y, ptr noalias %x) nounwind uwtable {
565+
entry:
566+
%cmp6 = icmp sgt i32 %n, 0
567+
br i1 %cmp6, label %for.body, label %for.end
568+
569+
for.body: ; preds = %entry, %for.body
570+
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
571+
%arrayidx = getelementptr inbounds float, ptr %y, i64 %indvars.iv
572+
%0 = load float, ptr %arrayidx, align 4
573+
%call = tail call float @llvm.atan.f32(float %0) nounwind readnone
574+
%arrayidx2 = getelementptr inbounds float, ptr %x, i64 %indvars.iv
575+
store float %call, ptr %arrayidx2, align 4
576+
%indvars.iv.next = add i64 %indvars.iv, 1
577+
%lftr.wideiv = trunc i64 %indvars.iv.next to i32
578+
%exitcond = icmp eq i32 %lftr.wideiv, %n
579+
br i1 %exitcond, label %for.end, label %for.body
580+
581+
for.end: ; preds = %for.body, %entry
582+
ret void
583+
}
584+
509585
;CHECK-LABEL: @sinh_f32(
510586
;CHECK: vsinhf{{.*}}<4 x float>
511587
;CHECK: ret void
@@ -531,6 +607,31 @@ for.end: ; preds = %for.body, %entry
531607
ret void
532608
}
533609

610+
;CHECK-LABEL: @sinh_f32_intrinsic(
611+
;CHECK: vsinhf{{.*}}<4 x float>
612+
;CHECK: ret void
613+
declare float @llvm.sinh.f32(float) nounwind readnone
614+
define void @sinh_f32_intrinsic(i32 %n, ptr noalias %y, ptr noalias %x) nounwind uwtable {
615+
entry:
616+
%cmp6 = icmp sgt i32 %n, 0
617+
br i1 %cmp6, label %for.body, label %for.end
618+
619+
for.body: ; preds = %entry, %for.body
620+
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
621+
%arrayidx = getelementptr inbounds float, ptr %y, i64 %indvars.iv
622+
%0 = load float, ptr %arrayidx, align 4
623+
%call = tail call float @llvm.sinh.f32(float %0) nounwind readnone
624+
%arrayidx2 = getelementptr inbounds float, ptr %x, i64 %indvars.iv
625+
store float %call, ptr %arrayidx2, align 4
626+
%indvars.iv.next = add i64 %indvars.iv, 1
627+
%lftr.wideiv = trunc i64 %indvars.iv.next to i32
628+
%exitcond = icmp eq i32 %lftr.wideiv, %n
629+
br i1 %exitcond, label %for.end, label %for.body
630+
631+
for.end: ; preds = %for.body, %entry
632+
ret void
633+
}
634+
534635
;CHECK-LABEL: @cosh_f32(
535636
;CHECK: vcoshf{{.*}}<4 x float>
536637
;CHECK: ret void
@@ -556,6 +657,31 @@ for.end: ; preds = %for.body, %entry
556657
ret void
557658
}
558659

660+
;CHECK-LABEL: @cosh_f32_intrinsic(
661+
;CHECK: vcoshf{{.*}}<4 x float>
662+
;CHECK: ret void
663+
declare float @llvm.cosh.f32(float) nounwind readnone
664+
define void @cosh_f32_intrinsic(i32 %n, ptr noalias %y, ptr noalias %x) nounwind uwtable {
665+
entry:
666+
%cmp6 = icmp sgt i32 %n, 0
667+
br i1 %cmp6, label %for.body, label %for.end
668+
669+
for.body: ; preds = %entry, %for.body
670+
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
671+
%arrayidx = getelementptr inbounds float, ptr %y, i64 %indvars.iv
672+
%0 = load float, ptr %arrayidx, align 4
673+
%call = tail call float @llvm.cosh.f32(float %0) nounwind readnone
674+
%arrayidx2 = getelementptr inbounds float, ptr %x, i64 %indvars.iv
675+
store float %call, ptr %arrayidx2, align 4
676+
%indvars.iv.next = add i64 %indvars.iv, 1
677+
%lftr.wideiv = trunc i64 %indvars.iv.next to i32
678+
%exitcond = icmp eq i32 %lftr.wideiv, %n
679+
br i1 %exitcond, label %for.end, label %for.body
680+
681+
for.end: ; preds = %for.body, %entry
682+
ret void
683+
}
684+
559685
;CHECK-LABEL: @tanh_f32(
560686
;CHECK: vtanhf{{.*}}<4 x float>
561687
;CHECK: ret void
@@ -581,6 +707,31 @@ for.end: ; preds = %for.body, %entry
581707
ret void
582708
}
583709

710+
;CHECK-LABEL: @tanh_f32_intrinsic(
711+
;CHECK: vtanhf{{.*}}<4 x float>
712+
;CHECK: ret void
713+
declare float @llvm.tanh.f32(float) nounwind readnone
714+
define void @tanh_f32_intrinsic(i32 %n, ptr noalias %y, ptr noalias %x) nounwind uwtable {
715+
entry:
716+
%cmp6 = icmp sgt i32 %n, 0
717+
br i1 %cmp6, label %for.body, label %for.end
718+
719+
for.body: ; preds = %entry, %for.body
720+
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
721+
%arrayidx = getelementptr inbounds float, ptr %y, i64 %indvars.iv
722+
%0 = load float, ptr %arrayidx, align 4
723+
%call = tail call float @llvm.tanh.f32(float %0) nounwind readnone
724+
%arrayidx2 = getelementptr inbounds float, ptr %x, i64 %indvars.iv
725+
store float %call, ptr %arrayidx2, align 4
726+
%indvars.iv.next = add i64 %indvars.iv, 1
727+
%lftr.wideiv = trunc i64 %indvars.iv.next to i32
728+
%exitcond = icmp eq i32 %lftr.wideiv, %n
729+
br i1 %exitcond, label %for.end, label %for.body
730+
731+
for.end: ; preds = %for.body, %entry
732+
ret void
733+
}
734+
584735
;CHECK-LABEL: @asinh_f32(
585736
;CHECK: vasinhf{{.*}}<4 x float>
586737
;CHECK: ret void

0 commit comments

Comments
 (0)