Index: llvm/lib/Target/ARM/ARMInstrMVE.td =================================================================== --- llvm/lib/Target/ARM/ARMInstrMVE.td +++ llvm/lib/Target/ARM/ARMInstrMVE.td @@ -2485,6 +2485,25 @@ def MVE_VCVTf32s32n : MVE_VCVT_fp_int<"f32.s32", 0b10, 0b00>; def MVE_VCVTf32u32n : MVE_VCVT_fp_int<"f32.u32", 0b10, 0b01>; +let Predicates = [HasMVEFloat] in { +def : Pat<(v4i32 (fp_to_sint (v4f32 MQPR:$src))), + (v4i32 (MVE_VCVTs32f32z (v4f32 MQPR:$src)))>; +def : Pat<(v4i32 (fp_to_uint (v4f32 MQPR:$src))), + (v4i32 (MVE_VCVTu32f32z (v4f32 MQPR:$src)))>; +def : Pat<(v8i16 (fp_to_sint (v8f16 MQPR:$src))), + (v8i16 (MVE_VCVTs16f16z (v8f16 MQPR:$src)))>; +def : Pat<(v8i16 (fp_to_uint (v8f16 MQPR:$src))), + (v8i16 (MVE_VCVTu16f16z (v8f16 MQPR:$src)))>; +def : Pat<(v4f32 (sint_to_fp (v4i32 MQPR:$src))), + (v4f32 (MVE_VCVTf32s32n (v4i32 MQPR:$src)))>; +def : Pat<(v4f32 (uint_to_fp (v4i32 MQPR:$src))), + (v4f32 (MVE_VCVTf32u32n (v4i32 MQPR:$src)))>; +def : Pat<(v8f16 (sint_to_fp (v8i16 MQPR:$src))), + (v8f16 (MVE_VCVTf16s16n (v8i16 MQPR:$src)))>; +def : Pat<(v8f16 (uint_to_fp (v8i16 MQPR:$src))), + (v8f16 (MVE_VCVTf16u16n (v8i16 MQPR:$src)))>; +} + class MVE_VABSNEG_fp size, bit negate, list pattern=[]> : MVE_float @foo_float_int32(<4 x i32> %src) { +; CHECK-LABEL: foo_float_int32: +; CHECK: @ %bb.0: @ %entry +; CHECK-NEXT: vcvt.f32.s32 q0, q0 +; CHECK-NEXT: bx lr +entry: + %out = sitofp <4 x i32> %src to <4 x float> + ret <4 x float> %out +} + +define arm_aapcs_vfpcc <4 x float> @foo_float_uint32(<4 x i32> %src) { +; CHECK-LABEL: foo_float_uint32: +; CHECK: @ %bb.0: @ %entry +; CHECK-NEXT: vcvt.f32.u32 q0, q0 +; CHECK-NEXT: bx lr +entry: + %out = uitofp <4 x i32> %src to <4 x float> + ret <4 x float> %out +} + +define arm_aapcs_vfpcc <4 x i32> @foo_int32_float(<4 x float> %src) { +; CHECK-LABEL: foo_int32_float: +; CHECK: @ %bb.0: @ %entry +; CHECK-NEXT: vcvt.s32.f32 q0, q0 +; CHECK-NEXT: bx lr +entry: + %out = fptosi <4 x float> %src to <4 x i32> + ret <4 x i32> %out +} + +define arm_aapcs_vfpcc <4 x i32> @foo_uint32_float(<4 x float> %src) { +; CHECK-LABEL: foo_uint32_float: +; CHECK: @ %bb.0: @ %entry +; CHECK-NEXT: vcvt.u32.f32 q0, q0 +; CHECK-NEXT: bx lr +entry: + %out = fptoui <4 x float> %src to <4 x i32> + ret <4 x i32> %out +} + +define arm_aapcs_vfpcc <8 x half> @foo_half_int16(<8 x i16> %src) { +; CHECK-LABEL: foo_half_int16: +; CHECK: @ %bb.0: @ %entry +; CHECK-NEXT: vcvt.f16.s16 q0, q0 +; CHECK-NEXT: bx lr +entry: + %out = sitofp <8 x i16> %src to <8 x half> + ret <8 x half> %out +} + +define arm_aapcs_vfpcc <8 x half> @foo_half_uint16(<8 x i16> %src) { +; CHECK-LABEL: foo_half_uint16: +; CHECK: @ %bb.0: @ %entry +; CHECK-NEXT: vcvt.f16.u16 q0, q0 +; CHECK-NEXT: bx lr +entry: + %out = uitofp <8 x i16> %src to <8 x half> + ret <8 x half> %out +} + +define arm_aapcs_vfpcc <8 x i16> @foo_int16_half(<8 x half> %src) { +; CHECK-LABEL: foo_int16_half: +; CHECK: @ %bb.0: @ %entry +; CHECK-NEXT: vcvt.s16.f16 q0, q0 +; CHECK-NEXT: bx lr +entry: + %out = fptosi <8 x half> %src to <8 x i16> + ret <8 x i16> %out +} + +define arm_aapcs_vfpcc <8 x i16> @foo_uint16_half(<8 x half> %src) { +; CHECK-LABEL: foo_uint16_half: +; CHECK: @ %bb.0: @ %entry +; CHECK-NEXT: vcvt.u16.f16 q0, q0 +; CHECK-NEXT: bx lr +entry: + %out = fptoui <8 x half> %src to <8 x i16> + ret <8 x i16> %out +}