Skip to content

Commit 49bac13

Browse files
committed
[CostModel][X86] Add test coverage for rint/lrint/llrint fp calls
1 parent aa5ff68 commit 49bac13

File tree

4 files changed

+960
-0
lines changed

4 files changed

+960
-0
lines changed

llvm/test/Analysis/CostModel/X86/arith-fp-codesize.ll

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,147 @@ define i32 @fma(i32 %arg) {
616616
ret i32 undef
617617
}
618618

619+
define i32 @rint(i32 %arg) {
620+
; SSE1-LABEL: 'rint'
621+
; SSE1-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %F32 = call float @llvm.rint.f32(float undef)
622+
; SSE1-NEXT: Cost Model: Found an estimated cost of 7 for instruction: %V4F32 = call <4 x float> @llvm.rint.v4f32(<4 x float> undef)
623+
; SSE1-NEXT: Cost Model: Found an estimated cost of 14 for instruction: %V8F32 = call <8 x float> @llvm.rint.v8f32(<8 x float> undef)
624+
; SSE1-NEXT: Cost Model: Found an estimated cost of 28 for instruction: %V16F32 = call <16 x float> @llvm.rint.v16f32(<16 x float> undef)
625+
; SSE1-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %F64 = call double @llvm.rint.f64(double undef)
626+
; SSE1-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V2F64 = call <2 x double> @llvm.rint.v2f64(<2 x double> undef)
627+
; SSE1-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V4F64 = call <4 x double> @llvm.rint.v4f64(<4 x double> undef)
628+
; SSE1-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V8F64 = call <8 x double> @llvm.rint.v8f64(<8 x double> undef)
629+
; SSE1-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 undef
630+
;
631+
; AVX-LABEL: 'rint'
632+
; AVX-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %F32 = call float @llvm.rint.f32(float undef)
633+
; AVX-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %V4F32 = call <4 x float> @llvm.rint.v4f32(<4 x float> undef)
634+
; AVX-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %V8F32 = call <8 x float> @llvm.rint.v8f32(<8 x float> undef)
635+
; AVX-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V16F32 = call <16 x float> @llvm.rint.v16f32(<16 x float> undef)
636+
; AVX-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %F64 = call double @llvm.rint.f64(double undef)
637+
; AVX-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %V2F64 = call <2 x double> @llvm.rint.v2f64(<2 x double> undef)
638+
; AVX-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %V4F64 = call <4 x double> @llvm.rint.v4f64(<4 x double> undef)
639+
; AVX-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V8F64 = call <8 x double> @llvm.rint.v8f64(<8 x double> undef)
640+
; AVX-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 undef
641+
;
642+
; AVX512-LABEL: 'rint'
643+
; AVX512-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %F32 = call float @llvm.rint.f32(float undef)
644+
; AVX512-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %V4F32 = call <4 x float> @llvm.rint.v4f32(<4 x float> undef)
645+
; AVX512-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %V8F32 = call <8 x float> @llvm.rint.v8f32(<8 x float> undef)
646+
; AVX512-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %V16F32 = call <16 x float> @llvm.rint.v16f32(<16 x float> undef)
647+
; AVX512-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %F64 = call double @llvm.rint.f64(double undef)
648+
; AVX512-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %V2F64 = call <2 x double> @llvm.rint.v2f64(<2 x double> undef)
649+
; AVX512-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %V4F64 = call <4 x double> @llvm.rint.v4f64(<4 x double> undef)
650+
; AVX512-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %V8F64 = call <8 x double> @llvm.rint.v8f64(<8 x double> undef)
651+
; AVX512-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 undef
652+
;
653+
%F32 = call float @llvm.rint.f32.f32(float undef)
654+
%V4F32 = call <4 x float> @llvm.rint.v4f32.v4f32(<4 x float> undef)
655+
%V8F32 = call <8 x float> @llvm.rint.v8f32.v8f32(<8 x float> undef)
656+
%V16F32 = call <16 x float> @llvm.rint.v16f32.v16f32(<16 x float> undef)
657+
658+
%F64 = call double @llvm.rint.f64.f64(double undef)
659+
%V2F64 = call <2 x double> @llvm.rint.v2f64.v2f64(<2 x double> undef)
660+
%V4F64 = call <4 x double> @llvm.rint.v4f64.v4f64(<4 x double> undef)
661+
%V8F64 = call <8 x double> @llvm.rint.v8f64.v8f64(<8 x double> undef)
662+
663+
ret i32 undef
664+
}
665+
666+
define i32 @lrint(i32 %arg) {
667+
; SSE1-LABEL: 'lrint'
668+
; SSE1-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %F32 = call i32 @llvm.lrint.i32.f32(float undef)
669+
; SSE1-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V4F32 = call <4 x i32> @llvm.lrint.v4i32.v4f32(<4 x float> undef)
670+
; SSE1-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %V8F32 = call <8 x i32> @llvm.lrint.v8i32.v8f32(<8 x float> undef)
671+
; SSE1-NEXT: Cost Model: Found an estimated cost of 32 for instruction: %V16F32 = call <16 x i32> @llvm.lrint.v16i32.v16f32(<16 x float> undef)
672+
; SSE1-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %F64 = call i32 @llvm.lrint.i32.f64(double undef)
673+
; SSE1-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V2F64 = call <2 x i32> @llvm.lrint.v2i32.v2f64(<2 x double> undef)
674+
; SSE1-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V4F64 = call <4 x i32> @llvm.lrint.v4i32.v4f64(<4 x double> undef)
675+
; SSE1-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %V8F64 = call <8 x i32> @llvm.lrint.v8i32.v8f64(<8 x double> undef)
676+
; SSE1-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 undef
677+
;
678+
; AVX-LABEL: 'lrint'
679+
; AVX-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %F32 = call i32 @llvm.lrint.i32.f32(float undef)
680+
; AVX-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V4F32 = call <4 x i32> @llvm.lrint.v4i32.v4f32(<4 x float> undef)
681+
; AVX-NEXT: Cost Model: Found an estimated cost of 17 for instruction: %V8F32 = call <8 x i32> @llvm.lrint.v8i32.v8f32(<8 x float> undef)
682+
; AVX-NEXT: Cost Model: Found an estimated cost of 34 for instruction: %V16F32 = call <16 x i32> @llvm.lrint.v16i32.v16f32(<16 x float> undef)
683+
; AVX-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %F64 = call i32 @llvm.lrint.i32.f64(double undef)
684+
; AVX-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V2F64 = call <2 x i32> @llvm.lrint.v2i32.v2f64(<2 x double> undef)
685+
; AVX-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V4F64 = call <4 x i32> @llvm.lrint.v4i32.v4f64(<4 x double> undef)
686+
; AVX-NEXT: Cost Model: Found an estimated cost of 17 for instruction: %V8F64 = call <8 x i32> @llvm.lrint.v8i32.v8f64(<8 x double> undef)
687+
; AVX-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 undef
688+
;
689+
; AVX512-LABEL: 'lrint'
690+
; AVX512-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %F32 = call i32 @llvm.lrint.i32.f32(float undef)
691+
; AVX512-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V4F32 = call <4 x i32> @llvm.lrint.v4i32.v4f32(<4 x float> undef)
692+
; AVX512-NEXT: Cost Model: Found an estimated cost of 17 for instruction: %V8F32 = call <8 x i32> @llvm.lrint.v8i32.v8f32(<8 x float> undef)
693+
; AVX512-NEXT: Cost Model: Found an estimated cost of 35 for instruction: %V16F32 = call <16 x i32> @llvm.lrint.v16i32.v16f32(<16 x float> undef)
694+
; AVX512-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %F64 = call i32 @llvm.lrint.i32.f64(double undef)
695+
; AVX512-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V2F64 = call <2 x i32> @llvm.lrint.v2i32.v2f64(<2 x double> undef)
696+
; AVX512-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V4F64 = call <4 x i32> @llvm.lrint.v4i32.v4f64(<4 x double> undef)
697+
; AVX512-NEXT: Cost Model: Found an estimated cost of 17 for instruction: %V8F64 = call <8 x i32> @llvm.lrint.v8i32.v8f64(<8 x double> undef)
698+
; AVX512-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 undef
699+
;
700+
%F32 = call i32 @llvm.lrint.i32.f32(float undef)
701+
%V4F32 = call <4 x i32> @llvm.lrint.v4i32.v4f32(<4 x float> undef)
702+
%V8F32 = call <8 x i32> @llvm.lrint.v8i32.v8f32(<8 x float> undef)
703+
%V16F32 = call <16 x i32> @llvm.lrint.v16i32.v16f32(<16 x float> undef)
704+
705+
%F64 = call i32 @llvm.lrint.i32.f64(double undef)
706+
%V2F64 = call <2 x i32> @llvm.lrint.v2i32.v2f64(<2 x double> undef)
707+
%V4F64 = call <4 x i32> @llvm.lrint.v4i32.v4f64(<4 x double> undef)
708+
%V8F64 = call <8 x i32> @llvm.lrint.v8i32.v8f64(<8 x double> undef)
709+
710+
ret i32 undef
711+
}
712+
713+
define i32 @llrint(i32 %arg) {
714+
; SSE1-LABEL: 'llrint'
715+
; SSE1-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %F32 = call i64 @llvm.llrint.i64.f32(float undef)
716+
; SSE1-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V4F32 = call <4 x i64> @llvm.llrint.v4i64.v4f32(<4 x float> undef)
717+
; SSE1-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %V8F32 = call <8 x i64> @llvm.llrint.v8i64.v8f32(<8 x float> undef)
718+
; SSE1-NEXT: Cost Model: Found an estimated cost of 32 for instruction: %V16F32 = call <16 x i64> @llvm.llrint.v16i64.v16f32(<16 x float> undef)
719+
; SSE1-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %F64 = call i64 @llvm.llrint.i64.f64(double undef)
720+
; SSE1-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V2F64 = call <2 x i64> @llvm.llrint.v2i64.v2f64(<2 x double> undef)
721+
; SSE1-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V4F64 = call <4 x i64> @llvm.llrint.v4i64.v4f64(<4 x double> undef)
722+
; SSE1-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %V8F64 = call <8 x i64> @llvm.llrint.v8i64.v8f64(<8 x double> undef)
723+
; SSE1-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 undef
724+
;
725+
; AVX-LABEL: 'llrint'
726+
; AVX-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %F32 = call i64 @llvm.llrint.i64.f32(float undef)
727+
; AVX-NEXT: Cost Model: Found an estimated cost of 9 for instruction: %V4F32 = call <4 x i64> @llvm.llrint.v4i64.v4f32(<4 x float> undef)
728+
; AVX-NEXT: Cost Model: Found an estimated cost of 18 for instruction: %V8F32 = call <8 x i64> @llvm.llrint.v8i64.v8f32(<8 x float> undef)
729+
; AVX-NEXT: Cost Model: Found an estimated cost of 36 for instruction: %V16F32 = call <16 x i64> @llvm.llrint.v16i64.v16f32(<16 x float> undef)
730+
; AVX-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %F64 = call i64 @llvm.llrint.i64.f64(double undef)
731+
; AVX-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V2F64 = call <2 x i64> @llvm.llrint.v2i64.v2f64(<2 x double> undef)
732+
; AVX-NEXT: Cost Model: Found an estimated cost of 9 for instruction: %V4F64 = call <4 x i64> @llvm.llrint.v4i64.v4f64(<4 x double> undef)
733+
; AVX-NEXT: Cost Model: Found an estimated cost of 18 for instruction: %V8F64 = call <8 x i64> @llvm.llrint.v8i64.v8f64(<8 x double> undef)
734+
; AVX-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 undef
735+
;
736+
; AVX512-LABEL: 'llrint'
737+
; AVX512-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %F32 = call i64 @llvm.llrint.i64.f32(float undef)
738+
; AVX512-NEXT: Cost Model: Found an estimated cost of 9 for instruction: %V4F32 = call <4 x i64> @llvm.llrint.v4i64.v4f32(<4 x float> undef)
739+
; AVX512-NEXT: Cost Model: Found an estimated cost of 19 for instruction: %V8F32 = call <8 x i64> @llvm.llrint.v8i64.v8f32(<8 x float> undef)
740+
; AVX512-NEXT: Cost Model: Found an estimated cost of 38 for instruction: %V16F32 = call <16 x i64> @llvm.llrint.v16i64.v16f32(<16 x float> undef)
741+
; AVX512-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %F64 = call i64 @llvm.llrint.i64.f64(double undef)
742+
; AVX512-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V2F64 = call <2 x i64> @llvm.llrint.v2i64.v2f64(<2 x double> undef)
743+
; AVX512-NEXT: Cost Model: Found an estimated cost of 9 for instruction: %V4F64 = call <4 x i64> @llvm.llrint.v4i64.v4f64(<4 x double> undef)
744+
; AVX512-NEXT: Cost Model: Found an estimated cost of 19 for instruction: %V8F64 = call <8 x i64> @llvm.llrint.v8i64.v8f64(<8 x double> undef)
745+
; AVX512-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 undef
746+
;
747+
%F32 = call i64 @llvm.llrint.i64.f32(float undef)
748+
%V4F32 = call <4 x i64> @llvm.llrint.v4i64.v4f32(<4 x float> undef)
749+
%V8F32 = call <8 x i64> @llvm.llrint.v8i64.v8f32(<8 x float> undef)
750+
%V16F32 = call <16 x i64> @llvm.llrint.v16i64.v16f32(<16 x float> undef)
751+
752+
%F64 = call i64 @llvm.llrint.i64.f64(double undef)
753+
%V2F64 = call <2 x i64> @llvm.llrint.v2i64.v2f64(<2 x double> undef)
754+
%V4F64 = call <4 x i64> @llvm.llrint.v4i64.v4f64(<4 x double> undef)
755+
%V8F64 = call <8 x i64> @llvm.llrint.v8i64.v8f64(<8 x double> undef)
756+
757+
ret i32 undef
758+
}
759+
619760
declare float @llvm.sqrt.f32(float)
620761
declare <4 x float> @llvm.sqrt.v4f32(<4 x float>)
621762
declare <8 x float> @llvm.sqrt.v8f32(<8 x float>)

0 commit comments

Comments
 (0)