diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 28b49d98336e..5426656f256a 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -1358,9 +1358,11 @@ void X86TargetLowering::resetOperationActions() { setOperationAction(ISD::FP_TO_SINT, MVT::v16i32, Legal); setOperationAction(ISD::FP_TO_UINT, MVT::v16i32, Legal); setOperationAction(ISD::FP_TO_UINT, MVT::v8i32, Legal); + setOperationAction(ISD::FP_TO_UINT, MVT::v4i32, Legal); setOperationAction(ISD::SINT_TO_FP, MVT::v16i32, Legal); setOperationAction(ISD::UINT_TO_FP, MVT::v16i32, Legal); setOperationAction(ISD::UINT_TO_FP, MVT::v8i32, Legal); + setOperationAction(ISD::UINT_TO_FP, MVT::v4i32, Legal); setOperationAction(ISD::FP_ROUND, MVT::v8f32, Legal); setOperationAction(ISD::FP_EXTEND, MVT::v8f32, Legal); diff --git a/llvm/lib/Target/X86/X86InstrAVX512.td b/llvm/lib/Target/X86/X86InstrAVX512.td index 2c5edf689b9f..1bc58fe66302 100644 --- a/llvm/lib/Target/X86/X86InstrAVX512.td +++ b/llvm/lib/Target/X86/X86InstrAVX512.td @@ -3112,6 +3112,17 @@ def : Pat<(v8i32 (fp_to_uint (v8f32 VR256X:$src1))), (EXTRACT_SUBREG (v16i32 (VCVTTPS2UDQZrr (v16f32 (SUBREG_TO_REG (i32 0), VR256X:$src1, sub_ymm)))), sub_ymm)>; +def : Pat<(v4i32 (fp_to_uint (v4f32 VR128X:$src1))), + (EXTRACT_SUBREG (v16i32 (VCVTTPS2UDQZrr + (v16f32 (SUBREG_TO_REG (i32 0), VR128X:$src1, sub_xmm)))), sub_xmm)>; + +def : Pat<(v8f32 (uint_to_fp (v8i32 VR256X:$src1))), + (EXTRACT_SUBREG (v16f32 (VCVTUDQ2PSZrr + (v16i32 (SUBREG_TO_REG (i32 0), VR256X:$src1, sub_ymm)))), sub_ymm)>; + +def : Pat<(v4f32 (uint_to_fp (v4i32 VR128X:$src1))), + (EXTRACT_SUBREG (v16f32 (VCVTUDQ2PSZrr + (v16i32 (SUBREG_TO_REG (i32 0), VR128X:$src1, sub_xmm)))), sub_xmm)>; def : Pat<(v16f32 (int_x86_avx512_mask_cvtdq2ps_512 (v16i32 VR512:$src), (bc_v16f32 (v16i32 immAllZerosV)), (i16 -1), imm:$rc)), diff --git a/llvm/test/CodeGen/X86/avx512-cvt.ll b/llvm/test/CodeGen/X86/avx512-cvt.ll index 1d83485adeca..2476ea1253e6 100644 --- a/llvm/test/CodeGen/X86/avx512-cvt.ll +++ b/llvm/test/CodeGen/X86/avx512-cvt.ll @@ -24,6 +24,22 @@ define <16 x i32> @fptoui00(<16 x float> %a) nounwind { ret <16 x i32> %b } +; CHECK-LABEL: fptoui_256 +; CHECK: vcvttps2udq +; CHECK: ret +define <8 x i32> @fptoui_256(<8 x float> %a) nounwind { + %b = fptoui <8 x float> %a to <8 x i32> + ret <8 x i32> %b +} + +; CHECK-LABEL: fptoui_128 +; CHECK: vcvttps2udq +; CHECK: ret +define <4 x i32> @fptoui_128(<4 x float> %a) nounwind { + %b = fptoui <4 x float> %a to <4 x i32> + ret <4 x i32> %b +} + ; CHECK-LABEL: fptoui01 ; CHECK: vcvttpd2udq ; CHECK: ret @@ -184,6 +200,22 @@ define <16 x float> @uitof32(<16 x i32> %a) nounwind { ret <16 x float> %b } +; CHECK-LABEL: uitof32_256 +; CHECK: vcvtudq2ps +; CHECK: ret +define <8 x float> @uitof32_256(<8 x i32> %a) nounwind { + %b = uitofp <8 x i32> %a to <8 x float> + ret <8 x float> %b +} + +; CHECK-LABEL: uitof32_128 +; CHECK: vcvtudq2ps +; CHECK: ret +define <4 x float> @uitof32_128(<4 x i32> %a) nounwind { + %b = uitofp <4 x i32> %a to <4 x float> + ret <4 x float> %b +} + ; CHECK-LABEL: @fptosi02 ; CHECK: vcvttss2si {{.*}} encoding: [0x62 ; CHECK: ret