Author: TelGome Date: 2026-08-17T13:15:46+08:00 New Revision: 14c9bb98d432033a40c823c34681937af8564989
URL: https://github.com/llvm/llvm-project/commit/14c9bb98d432033a40c823c34681937af8564989 DIFF: https://github.com/llvm/llvm-project/commit/14c9bb98d432033a40c823c34681937af8564989.diff LOG: [RISCV][P-ext] Support Packed Narrowing Clip Pair (#215779) Added: Modified: clang/include/clang/Basic/BuiltinsRISCV.td clang/lib/CodeGen/TargetBuiltins/RISCV.cpp clang/lib/Headers/riscv_packed_simd.h clang/test/CodeGen/RISCV/rvp-intrinsics.c cross-project-tests/intrinsic-header-tests/riscv_packed_simd.c llvm/include/llvm/IR/IntrinsicsRISCV.td llvm/lib/Target/RISCV/RISCVISelLowering.cpp llvm/lib/Target/RISCV/RISCVInstrInfoP.td llvm/test/CodeGen/RISCV/rvp-simd-32.ll llvm/test/CodeGen/RISCV/rvp-simd-64.ll Removed: ################################################################################ diff --git a/clang/include/clang/Basic/BuiltinsRISCV.td b/clang/include/clang/Basic/BuiltinsRISCV.td index c7ee68415d001..b91b356d7a25d 100644 --- a/clang/include/clang/Basic/BuiltinsRISCV.td +++ b/clang/include/clang/Basic/BuiltinsRISCV.td @@ -309,6 +309,20 @@ def pzext_b_u16x4 : RISCVBuiltin<"_Vector<4, unsigned short>(_Vector<4, unsigned def pzext_h_u32x2 : RISCVBuiltin<"_Vector<2, unsigned int>(_Vector<2, unsigned int>)">; +// Packed Narrowing Clip Pair (32-bit) +def pnclipp_i8x4 : RISCVBuiltin<"_Vector<4, signed char>(_Vector<2, short>, _Vector<2, short>)">; +def pnclipup_u8x4 : RISCVBuiltin<"_Vector<4, unsigned char>(_Vector<2, unsigned short>, _Vector<2, unsigned short>)">; +def pnclipp_i16x2 : RISCVBuiltin<"_Vector<2, short>(int, int)">; +def pnclipup_u16x2 : RISCVBuiltin<"_Vector<2, unsigned short>(unsigned int, unsigned int)">; + +// Packed Narrowing Clip Pair (64-bit) +def pnclipp_i8x8 : RISCVBuiltin<"_Vector<8, signed char>(_Vector<4, short>, _Vector<4, short>)">; +def pnclipup_u8x8 : RISCVBuiltin<"_Vector<8, unsigned char>(_Vector<4, unsigned short>, _Vector<4, unsigned short>)">; +def pnclipp_i16x4 : RISCVBuiltin<"_Vector<4, short>(_Vector<2, int>, _Vector<2, int>)">; +def pnclipup_u16x4 : RISCVBuiltin<"_Vector<4, unsigned short>(_Vector<2, unsigned int>, _Vector<2, unsigned int>)">; +def pnclipp_i32x2 : RISCVBuiltin<"_Vector<2, int>(int64_t, int64_t)">; +def pnclipup_u32x2 : RISCVBuiltin<"_Vector<2, unsigned int>(uint64_t, uint64_t)">; + } // Features = "experimental-p" //===----------------------------------------------------------------------===// diff --git a/clang/lib/CodeGen/TargetBuiltins/RISCV.cpp b/clang/lib/CodeGen/TargetBuiltins/RISCV.cpp index a97f11223e6ae..eb98b38974b21 100644 --- a/clang/lib/CodeGen/TargetBuiltins/RISCV.cpp +++ b/clang/lib/CodeGen/TargetBuiltins/RISCV.cpp @@ -1463,7 +1463,18 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned BuiltinID, case RISCV::BI__builtin_riscv_predsumu_u16x4_u32: case RISCV::BI__builtin_riscv_predsumu_u8x8_u64: case RISCV::BI__builtin_riscv_predsumu_u16x4_u64: - case RISCV::BI__builtin_riscv_predsumu_u32x2_u64: { + case RISCV::BI__builtin_riscv_predsumu_u32x2_u64: + // Packed Narrowing Clip Pair + case RISCV::BI__builtin_riscv_pnclipp_i8x4: + case RISCV::BI__builtin_riscv_pnclipp_i8x8: + case RISCV::BI__builtin_riscv_pnclipp_i16x2: + case RISCV::BI__builtin_riscv_pnclipp_i16x4: + case RISCV::BI__builtin_riscv_pnclipp_i32x2: + case RISCV::BI__builtin_riscv_pnclipup_u8x4: + case RISCV::BI__builtin_riscv_pnclipup_u8x8: + case RISCV::BI__builtin_riscv_pnclipup_u16x2: + case RISCV::BI__builtin_riscv_pnclipup_u16x4: + case RISCV::BI__builtin_riscv_pnclipup_u32x2: { switch (BuiltinID) { default: llvm_unreachable("unexpected builtin ID"); @@ -1485,6 +1496,20 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned BuiltinID, case RISCV::BI__builtin_riscv_predsumu_u32x2_u64: ID = Intrinsic::riscv_predsumu; break; + case RISCV::BI__builtin_riscv_pnclipp_i8x4: + case RISCV::BI__builtin_riscv_pnclipp_i8x8: + case RISCV::BI__builtin_riscv_pnclipp_i16x2: + case RISCV::BI__builtin_riscv_pnclipp_i16x4: + case RISCV::BI__builtin_riscv_pnclipp_i32x2: + ID = Intrinsic::riscv_pnclipp; + break; + case RISCV::BI__builtin_riscv_pnclipup_u8x4: + case RISCV::BI__builtin_riscv_pnclipup_u8x8: + case RISCV::BI__builtin_riscv_pnclipup_u16x2: + case RISCV::BI__builtin_riscv_pnclipup_u16x4: + case RISCV::BI__builtin_riscv_pnclipup_u32x2: + ID = Intrinsic::riscv_pnclipup; + break; } IntrinsicTypes = {ResultType, Ops[0]->getType()}; diff --git a/clang/lib/Headers/riscv_packed_simd.h b/clang/lib/Headers/riscv_packed_simd.h index efec0dd9568f3..491e219bec297 100644 --- a/clang/lib/Headers/riscv_packed_simd.h +++ b/clang/lib/Headers/riscv_packed_simd.h @@ -781,6 +781,20 @@ __packed_binary_builtin(pmulqr_i16x4, int16x4_t, __builtin_riscv_pmulqr_i16x4) __packed_binary_builtin(pmulq_i32x2, int32x2_t, __builtin_riscv_pmulq_i32x2) __packed_binary_builtin(pmulqr_i32x2, int32x2_t, __builtin_riscv_pmulqr_i32x2) +/* Packed Narrowing Clip Pair (32-bit) */ +__packed_binary_builtin_cast(pnclipp_i8x4, int16x2_t, int8x4_t, __builtin_riscv_pnclipp_i8x4) +__packed_binary_builtin_cast(pnclipup_u8x4, uint16x2_t, uint8x4_t, __builtin_riscv_pnclipup_u8x4) +__packed_binary_builtin_cast(pnclipp_i16x2, int, int16x2_t, __builtin_riscv_pnclipp_i16x2) +__packed_binary_builtin_cast(pnclipup_u16x2, unsigned int, uint16x2_t, __builtin_riscv_pnclipup_u16x2) + +/* Packed Narrowing Clip Pair (64-bit) */ +__packed_binary_builtin_cast(pnclipp_i8x8, int16x4_t, int8x8_t, __builtin_riscv_pnclipp_i8x8) +__packed_binary_builtin_cast(pnclipup_u8x8, uint16x4_t, uint8x8_t, __builtin_riscv_pnclipup_u8x8) +__packed_binary_builtin_cast(pnclipp_i16x4, int32x2_t, int16x4_t, __builtin_riscv_pnclipp_i16x4) +__packed_binary_builtin_cast(pnclipup_u16x4, uint32x2_t, uint16x4_t, __builtin_riscv_pnclipup_u16x4) +__packed_binary_builtin_cast(pnclipp_i32x2, int64_t, int32x2_t, __builtin_riscv_pnclipp_i32x2) +__packed_binary_builtin_cast(pnclipup_u32x2, uint64_t, uint32x2_t, __builtin_riscv_pnclipup_u32x2) + /* Reinterpret Casts, Packed <-> Scalar (32-bit) */ __packed_reinterpret(u8x4_u32, uint32_t, uint8x4_t) __packed_reinterpret(u16x2_u32, uint32_t, uint16x2_t) diff --git a/clang/test/CodeGen/RISCV/rvp-intrinsics.c b/clang/test/CodeGen/RISCV/rvp-intrinsics.c index 97100deccb3d0..d6afc4d18cc6a 100644 --- a/clang/test/CodeGen/RISCV/rvp-intrinsics.c +++ b/clang/test/CodeGen/RISCV/rvp-intrinsics.c @@ -9497,3 +9497,211 @@ int16x4_t test_pnziph_i16x4(int32x2_t rs1, int32x2_t rs2) { uint16x4_t test_pnziph_u16x4(uint32x2_t rs1, uint32x2_t rs2) { return __riscv_pnziph_u16x4(rs1, rs2); } + +/* Packed Narrowing Clip Pair (32-bit) */ + +// RV32-LABEL: define dso_local i32 @test_pnclipp_i8x4( +// RV32-SAME: i32 noundef [[RS1_COERCE:%.*]], i32 noundef [[RS2_COERCE:%.*]]) #[[ATTR0]] { +// RV32-NEXT: [[ENTRY:.*:]] +// RV32-NEXT: [[TMP0:%.*]] = bitcast i32 [[RS1_COERCE]] to <2 x i16> +// RV32-NEXT: [[TMP1:%.*]] = bitcast i32 [[RS2_COERCE]] to <2 x i16> +// RV32-NEXT: [[TMP2:%.*]] = call <4 x i8> @llvm.riscv.pnclipp.v4i8.v2i16(<2 x i16> [[TMP0]], <2 x i16> [[TMP1]]) +// RV32-NEXT: [[TMP3:%.*]] = bitcast <4 x i8> [[TMP2]] to i32 +// RV32-NEXT: ret i32 [[TMP3]] +// +// RV64-LABEL: define dso_local i32 @test_pnclipp_i8x4( +// RV64-SAME: i32 noundef [[RS1_COERCE:%.*]], i32 noundef [[RS2_COERCE:%.*]]) #[[ATTR0]] { +// RV64-NEXT: [[ENTRY:.*:]] +// RV64-NEXT: [[TMP0:%.*]] = bitcast i32 [[RS1_COERCE]] to <2 x i16> +// RV64-NEXT: [[TMP1:%.*]] = bitcast i32 [[RS2_COERCE]] to <2 x i16> +// RV64-NEXT: [[TMP2:%.*]] = call <4 x i8> @llvm.riscv.pnclipp.v4i8.v2i16(<2 x i16> [[TMP0]], <2 x i16> [[TMP1]]) +// RV64-NEXT: [[TMP3:%.*]] = bitcast <4 x i8> [[TMP2]] to i32 +// RV64-NEXT: ret i32 [[TMP3]] +// +int8x4_t test_pnclipp_i8x4(int16x2_t rs1, int16x2_t rs2) { + return __riscv_pnclipp_i8x4(rs1, rs2); +} + +// RV32-LABEL: define dso_local i32 @test_pnclipup_u8x4( +// RV32-SAME: i32 noundef [[RS1_COERCE:%.*]], i32 noundef [[RS2_COERCE:%.*]]) #[[ATTR0]] { +// RV32-NEXT: [[ENTRY:.*:]] +// RV32-NEXT: [[TMP0:%.*]] = bitcast i32 [[RS1_COERCE]] to <2 x i16> +// RV32-NEXT: [[TMP1:%.*]] = bitcast i32 [[RS2_COERCE]] to <2 x i16> +// RV32-NEXT: [[TMP2:%.*]] = call <4 x i8> @llvm.riscv.pnclipup.v4i8.v2i16(<2 x i16> [[TMP0]], <2 x i16> [[TMP1]]) +// RV32-NEXT: [[TMP3:%.*]] = bitcast <4 x i8> [[TMP2]] to i32 +// RV32-NEXT: ret i32 [[TMP3]] +// +// RV64-LABEL: define dso_local i32 @test_pnclipup_u8x4( +// RV64-SAME: i32 noundef [[RS1_COERCE:%.*]], i32 noundef [[RS2_COERCE:%.*]]) #[[ATTR0]] { +// RV64-NEXT: [[ENTRY:.*:]] +// RV64-NEXT: [[TMP0:%.*]] = bitcast i32 [[RS1_COERCE]] to <2 x i16> +// RV64-NEXT: [[TMP1:%.*]] = bitcast i32 [[RS2_COERCE]] to <2 x i16> +// RV64-NEXT: [[TMP2:%.*]] = call <4 x i8> @llvm.riscv.pnclipup.v4i8.v2i16(<2 x i16> [[TMP0]], <2 x i16> [[TMP1]]) +// RV64-NEXT: [[TMP3:%.*]] = bitcast <4 x i8> [[TMP2]] to i32 +// RV64-NEXT: ret i32 [[TMP3]] +// +uint8x4_t test_pnclipup_u8x4(uint16x2_t rs1, uint16x2_t rs2) { + return __riscv_pnclipup_u8x4(rs1, rs2); +} + +// RV32-LABEL: define dso_local i32 @test_pnclipp_i16x2( +// RV32-SAME: i32 noundef [[RS1:%.*]], i32 noundef [[RS2:%.*]]) #[[ATTR0]] { +// RV32-NEXT: [[ENTRY:.*:]] +// RV32-NEXT: [[TMP0:%.*]] = call <2 x i16> @llvm.riscv.pnclipp.v2i16.i32(i32 [[RS1]], i32 [[RS2]]) +// RV32-NEXT: [[TMP1:%.*]] = bitcast <2 x i16> [[TMP0]] to i32 +// RV32-NEXT: ret i32 [[TMP1]] +// +// RV64-LABEL: define dso_local i32 @test_pnclipp_i16x2( +// RV64-SAME: i32 noundef signext [[RS1:%.*]], i32 noundef signext [[RS2:%.*]]) #[[ATTR0]] { +// RV64-NEXT: [[ENTRY:.*:]] +// RV64-NEXT: [[TMP0:%.*]] = call <2 x i16> @llvm.riscv.pnclipp.v2i16.i32(i32 [[RS1]], i32 [[RS2]]) +// RV64-NEXT: [[TMP1:%.*]] = bitcast <2 x i16> [[TMP0]] to i32 +// RV64-NEXT: ret i32 [[TMP1]] +// +int16x2_t test_pnclipp_i16x2(int32_t rs1, int32_t rs2) { + return __riscv_pnclipp_i16x2(rs1, rs2); +} + +// RV32-LABEL: define dso_local i32 @test_pnclipup_u16x2( +// RV32-SAME: i32 noundef [[RS1:%.*]], i32 noundef [[RS2:%.*]]) #[[ATTR0]] { +// RV32-NEXT: [[ENTRY:.*:]] +// RV32-NEXT: [[TMP0:%.*]] = call <2 x i16> @llvm.riscv.pnclipup.v2i16.i32(i32 [[RS1]], i32 [[RS2]]) +// RV32-NEXT: [[TMP1:%.*]] = bitcast <2 x i16> [[TMP0]] to i32 +// RV32-NEXT: ret i32 [[TMP1]] +// +// RV64-LABEL: define dso_local i32 @test_pnclipup_u16x2( +// RV64-SAME: i32 noundef signext [[RS1:%.*]], i32 noundef signext [[RS2:%.*]]) #[[ATTR0]] { +// RV64-NEXT: [[ENTRY:.*:]] +// RV64-NEXT: [[TMP0:%.*]] = call <2 x i16> @llvm.riscv.pnclipup.v2i16.i32(i32 [[RS1]], i32 [[RS2]]) +// RV64-NEXT: [[TMP1:%.*]] = bitcast <2 x i16> [[TMP0]] to i32 +// RV64-NEXT: ret i32 [[TMP1]] +// +uint16x2_t test_pnclipup_u16x2(uint32_t rs1, uint32_t rs2) { + return __riscv_pnclipup_u16x2(rs1, rs2); +} + +/* Packed Narrowing Clip Pair (64-bit) */ + +// RV32-LABEL: define dso_local i64 @test_pnclipp_i8x8( +// RV32-SAME: i64 noundef [[RS1_COERCE:%.*]], i64 noundef [[RS2_COERCE:%.*]]) #[[ATTR0]] { +// RV32-NEXT: [[ENTRY:.*:]] +// RV32-NEXT: [[TMP0:%.*]] = bitcast i64 [[RS1_COERCE]] to <4 x i16> +// RV32-NEXT: [[TMP1:%.*]] = bitcast i64 [[RS2_COERCE]] to <4 x i16> +// RV32-NEXT: [[TMP2:%.*]] = call <8 x i8> @llvm.riscv.pnclipp.v8i8.v4i16(<4 x i16> [[TMP0]], <4 x i16> [[TMP1]]) +// RV32-NEXT: [[TMP3:%.*]] = bitcast <8 x i8> [[TMP2]] to i64 +// RV32-NEXT: ret i64 [[TMP3]] +// +// RV64-LABEL: define dso_local i64 @test_pnclipp_i8x8( +// RV64-SAME: i64 noundef [[RS1_COERCE:%.*]], i64 noundef [[RS2_COERCE:%.*]]) #[[ATTR0]] { +// RV64-NEXT: [[ENTRY:.*:]] +// RV64-NEXT: [[TMP0:%.*]] = bitcast i64 [[RS1_COERCE]] to <4 x i16> +// RV64-NEXT: [[TMP1:%.*]] = bitcast i64 [[RS2_COERCE]] to <4 x i16> +// RV64-NEXT: [[TMP2:%.*]] = call <8 x i8> @llvm.riscv.pnclipp.v8i8.v4i16(<4 x i16> [[TMP0]], <4 x i16> [[TMP1]]) +// RV64-NEXT: [[TMP3:%.*]] = bitcast <8 x i8> [[TMP2]] to i64 +// RV64-NEXT: ret i64 [[TMP3]] +// +int8x8_t test_pnclipp_i8x8(int16x4_t rs1, int16x4_t rs2) { + return __riscv_pnclipp_i8x8(rs1, rs2); +} + +// RV32-LABEL: define dso_local i64 @test_pnclipup_u8x8( +// RV32-SAME: i64 noundef [[RS1_COERCE:%.*]], i64 noundef [[RS2_COERCE:%.*]]) #[[ATTR0]] { +// RV32-NEXT: [[ENTRY:.*:]] +// RV32-NEXT: [[TMP0:%.*]] = bitcast i64 [[RS1_COERCE]] to <4 x i16> +// RV32-NEXT: [[TMP1:%.*]] = bitcast i64 [[RS2_COERCE]] to <4 x i16> +// RV32-NEXT: [[TMP2:%.*]] = call <8 x i8> @llvm.riscv.pnclipup.v8i8.v4i16(<4 x i16> [[TMP0]], <4 x i16> [[TMP1]]) +// RV32-NEXT: [[TMP3:%.*]] = bitcast <8 x i8> [[TMP2]] to i64 +// RV32-NEXT: ret i64 [[TMP3]] +// +// RV64-LABEL: define dso_local i64 @test_pnclipup_u8x8( +// RV64-SAME: i64 noundef [[RS1_COERCE:%.*]], i64 noundef [[RS2_COERCE:%.*]]) #[[ATTR0]] { +// RV64-NEXT: [[ENTRY:.*:]] +// RV64-NEXT: [[TMP0:%.*]] = bitcast i64 [[RS1_COERCE]] to <4 x i16> +// RV64-NEXT: [[TMP1:%.*]] = bitcast i64 [[RS2_COERCE]] to <4 x i16> +// RV64-NEXT: [[TMP2:%.*]] = call <8 x i8> @llvm.riscv.pnclipup.v8i8.v4i16(<4 x i16> [[TMP0]], <4 x i16> [[TMP1]]) +// RV64-NEXT: [[TMP3:%.*]] = bitcast <8 x i8> [[TMP2]] to i64 +// RV64-NEXT: ret i64 [[TMP3]] +// +uint8x8_t test_pnclipup_u8x8(uint16x4_t rs1, uint16x4_t rs2) { + return __riscv_pnclipup_u8x8(rs1, rs2); +} + +// RV32-LABEL: define dso_local i64 @test_pnclipp_i16x4( +// RV32-SAME: i64 noundef [[RS1_COERCE:%.*]], i64 noundef [[RS2_COERCE:%.*]]) #[[ATTR0]] { +// RV32-NEXT: [[ENTRY:.*:]] +// RV32-NEXT: [[TMP0:%.*]] = bitcast i64 [[RS1_COERCE]] to <2 x i32> +// RV32-NEXT: [[TMP1:%.*]] = bitcast i64 [[RS2_COERCE]] to <2 x i32> +// RV32-NEXT: [[TMP2:%.*]] = call <4 x i16> @llvm.riscv.pnclipp.v4i16.v2i32(<2 x i32> [[TMP0]], <2 x i32> [[TMP1]]) +// RV32-NEXT: [[TMP3:%.*]] = bitcast <4 x i16> [[TMP2]] to i64 +// RV32-NEXT: ret i64 [[TMP3]] +// +// RV64-LABEL: define dso_local i64 @test_pnclipp_i16x4( +// RV64-SAME: i64 noundef [[RS1_COERCE:%.*]], i64 noundef [[RS2_COERCE:%.*]]) #[[ATTR0]] { +// RV64-NEXT: [[ENTRY:.*:]] +// RV64-NEXT: [[TMP0:%.*]] = bitcast i64 [[RS1_COERCE]] to <2 x i32> +// RV64-NEXT: [[TMP1:%.*]] = bitcast i64 [[RS2_COERCE]] to <2 x i32> +// RV64-NEXT: [[TMP2:%.*]] = call <4 x i16> @llvm.riscv.pnclipp.v4i16.v2i32(<2 x i32> [[TMP0]], <2 x i32> [[TMP1]]) +// RV64-NEXT: [[TMP3:%.*]] = bitcast <4 x i16> [[TMP2]] to i64 +// RV64-NEXT: ret i64 [[TMP3]] +// +int16x4_t test_pnclipp_i16x4(int32x2_t rs1, int32x2_t rs2) { + return __riscv_pnclipp_i16x4(rs1, rs2); +} + +// RV32-LABEL: define dso_local i64 @test_pnclipup_u16x4( +// RV32-SAME: i64 noundef [[RS1_COERCE:%.*]], i64 noundef [[RS2_COERCE:%.*]]) #[[ATTR0]] { +// RV32-NEXT: [[ENTRY:.*:]] +// RV32-NEXT: [[TMP0:%.*]] = bitcast i64 [[RS1_COERCE]] to <2 x i32> +// RV32-NEXT: [[TMP1:%.*]] = bitcast i64 [[RS2_COERCE]] to <2 x i32> +// RV32-NEXT: [[TMP2:%.*]] = call <4 x i16> @llvm.riscv.pnclipup.v4i16.v2i32(<2 x i32> [[TMP0]], <2 x i32> [[TMP1]]) +// RV32-NEXT: [[TMP3:%.*]] = bitcast <4 x i16> [[TMP2]] to i64 +// RV32-NEXT: ret i64 [[TMP3]] +// +// RV64-LABEL: define dso_local i64 @test_pnclipup_u16x4( +// RV64-SAME: i64 noundef [[RS1_COERCE:%.*]], i64 noundef [[RS2_COERCE:%.*]]) #[[ATTR0]] { +// RV64-NEXT: [[ENTRY:.*:]] +// RV64-NEXT: [[TMP0:%.*]] = bitcast i64 [[RS1_COERCE]] to <2 x i32> +// RV64-NEXT: [[TMP1:%.*]] = bitcast i64 [[RS2_COERCE]] to <2 x i32> +// RV64-NEXT: [[TMP2:%.*]] = call <4 x i16> @llvm.riscv.pnclipup.v4i16.v2i32(<2 x i32> [[TMP0]], <2 x i32> [[TMP1]]) +// RV64-NEXT: [[TMP3:%.*]] = bitcast <4 x i16> [[TMP2]] to i64 +// RV64-NEXT: ret i64 [[TMP3]] +// +uint16x4_t test_pnclipup_u16x4(uint32x2_t rs1, uint32x2_t rs2) { + return __riscv_pnclipup_u16x4(rs1, rs2); +} + +// RV32-LABEL: define dso_local i64 @test_pnclipp_i32x2( +// RV32-SAME: i64 noundef [[RS1:%.*]], i64 noundef [[RS2:%.*]]) #[[ATTR0]] { +// RV32-NEXT: [[ENTRY:.*:]] +// RV32-NEXT: [[TMP0:%.*]] = call <2 x i32> @llvm.riscv.pnclipp.v2i32.i64(i64 [[RS1]], i64 [[RS2]]) +// RV32-NEXT: [[TMP1:%.*]] = bitcast <2 x i32> [[TMP0]] to i64 +// RV32-NEXT: ret i64 [[TMP1]] +// +// RV64-LABEL: define dso_local i64 @test_pnclipp_i32x2( +// RV64-SAME: i64 noundef [[RS1:%.*]], i64 noundef [[RS2:%.*]]) #[[ATTR0]] { +// RV64-NEXT: [[ENTRY:.*:]] +// RV64-NEXT: [[TMP0:%.*]] = call <2 x i32> @llvm.riscv.pnclipp.v2i32.i64(i64 [[RS1]], i64 [[RS2]]) +// RV64-NEXT: [[TMP1:%.*]] = bitcast <2 x i32> [[TMP0]] to i64 +// RV64-NEXT: ret i64 [[TMP1]] +// +int32x2_t test_pnclipp_i32x2(int64_t rs1, int64_t rs2) { + return __riscv_pnclipp_i32x2(rs1, rs2); +} + +// RV32-LABEL: define dso_local i64 @test_pnclipup_u32x2( +// RV32-SAME: i64 noundef [[RS1:%.*]], i64 noundef [[RS2:%.*]]) #[[ATTR0]] { +// RV32-NEXT: [[ENTRY:.*:]] +// RV32-NEXT: [[TMP0:%.*]] = call <2 x i32> @llvm.riscv.pnclipup.v2i32.i64(i64 [[RS1]], i64 [[RS2]]) +// RV32-NEXT: [[TMP1:%.*]] = bitcast <2 x i32> [[TMP0]] to i64 +// RV32-NEXT: ret i64 [[TMP1]] +// +// RV64-LABEL: define dso_local i64 @test_pnclipup_u32x2( +// RV64-SAME: i64 noundef [[RS1:%.*]], i64 noundef [[RS2:%.*]]) #[[ATTR0]] { +// RV64-NEXT: [[ENTRY:.*:]] +// RV64-NEXT: [[TMP0:%.*]] = call <2 x i32> @llvm.riscv.pnclipup.v2i32.i64(i64 [[RS1]], i64 [[RS2]]) +// RV64-NEXT: [[TMP1:%.*]] = bitcast <2 x i32> [[TMP0]] to i64 +// RV64-NEXT: ret i64 [[TMP1]] +// +uint32x2_t test_pnclipup_u32x2(uint64_t rs1, uint64_t rs2) { + return __riscv_pnclipup_u32x2(rs1, rs2); +} diff --git a/cross-project-tests/intrinsic-header-tests/riscv_packed_simd.c b/cross-project-tests/intrinsic-header-tests/riscv_packed_simd.c index 079ab22339780..eac091c66bba0 100644 --- a/cross-project-tests/intrinsic-header-tests/riscv_packed_simd.c +++ b/cross-project-tests/intrinsic-header-tests/riscv_packed_simd.c @@ -3000,3 +3000,79 @@ uint16x2_t test_punzipe_u16x2(uint16x4_t a) { return __riscv_punzipe_u16x2(a); } // RV32: pncvth.h // RV64: pncvth.wh uint16x2_t test_punzipo_u16x2(uint16x4_t a) { return __riscv_punzipo_u16x2(a); } + +// CHECK-LABEL: test_pnclipp_i8x4: +// RV32: pnclipi.b +// RV64: pnclipp.b +int8x4_t test_pnclipp_i8x4(int16x2_t a, int16x2_t b) { + return __riscv_pnclipp_i8x4(a, b); +} + +// CHECK-LABEL: test_pnclipup_u8x4: +// RV32: pnclipiu.b +// RV64: pnclipup.b +uint8x4_t test_pnclipup_u8x4(uint16x2_t a, uint16x2_t b) { + return __riscv_pnclipup_u8x4(a, b); +} + +// CHECK-LABEL: test_pnclipp_i16x2: +// RV32: pnclipi.h +// RV64: pnclipp.h +int16x2_t test_pnclipp_i16x2(int32_t a, int32_t b) { + return __riscv_pnclipp_i16x2(a, b); +} + +// CHECK-LABEL: test_pnclipup_u16x2: +// RV32: pnclipiu.h +// RV64: pnclipup.h +uint16x2_t test_pnclipup_u16x2(uint32_t a, uint32_t b) { + return __riscv_pnclipup_u16x2(a, b); +} + +// CHECK-LABEL: test_pnclipp_i8x8: +// RV32: pnclipi.b +// RV32: pnclipi.b +// RV64: pnclipp.b +int8x8_t test_pnclipp_i8x8(int16x4_t a, int16x4_t b) { + return __riscv_pnclipp_i8x8(a, b); +} + +// CHECK-LABEL: test_pnclipup_u8x8: +// RV32: pnclipiu.b +// RV32: pnclipiu.b +// RV64: pnclipup.b +uint8x8_t test_pnclipup_u8x8(uint16x4_t a, uint16x4_t b) { + return __riscv_pnclipup_u8x8(a, b); +} + +// CHECK-LABEL: test_pnclipp_i16x4: +// RV32: pnclipi.h +// RV32: pnclipi.h +// RV64: pnclipp.h +int16x4_t test_pnclipp_i16x4(int32x2_t a, int32x2_t b) { + return __riscv_pnclipp_i16x4(a, b); +} + +// CHECK-LABEL: test_pnclipup_u16x4: +// RV32: pnclipiu.h +// RV32: pnclipiu.h +// RV64: pnclipup.h +uint16x4_t test_pnclipup_u16x4(uint32x2_t a, uint32x2_t b) { + return __riscv_pnclipup_u16x4(a, b); +} + +// CHECK-LABEL: test_pnclipp_i32x2: +// RV32: nclipi +// RV32: nclipi +// RV64: pnclipp.w +int32x2_t test_pnclipp_i32x2(int64_t a, int64_t b) { + return __riscv_pnclipp_i32x2(a, b); +} + +// CHECK-LABEL: test_pnclipup_u32x2: +// RV32: nclipiu +// RV32: nclipiu +// RV64: pnclipup.w +uint32x2_t test_pnclipup_u32x2(uint64_t a, uint64_t b) { + return __riscv_pnclipup_u32x2(a, b); +} diff --git a/llvm/include/llvm/IR/IntrinsicsRISCV.td b/llvm/include/llvm/IR/IntrinsicsRISCV.td index 517d0e51ec406..d5bd6243bd1a6 100644 --- a/llvm/include/llvm/IR/IntrinsicsRISCV.td +++ b/llvm/include/llvm/IR/IntrinsicsRISCV.td @@ -2134,6 +2134,14 @@ class RVPBinaryIntrinsic [LLVMMatchType<0>], [IntrNoMem, IntrSpeculatable]>; def int_riscv_psabs : RVPUnaryIntrinsic; + + // Packed Narrowing Clip Pair + class RVPNarrowingClipIntrinsic + : DefaultAttrsIntrinsic<[llvm_anyvector_ty], + [llvm_any_ty, LLVMMatchType<1>], + [IntrNoMem, IntrSpeculatable]>; + def int_riscv_pnclipp : RVPNarrowingClipIntrinsic; + def int_riscv_pnclipup : RVPNarrowingClipIntrinsic; } // TargetPrefix = "riscv" //===----------------------------------------------------------------------===// diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp index 6202a12c7025b..6bd0a66767e6b 100644 --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -12302,6 +12302,51 @@ SDValue RISCVTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op, return DAG.getNode(Opc, DL, Op.getValueType(), Op.getOperand(1), Op.getOperand(2)); } + case Intrinsic::riscv_pnclipp: + case Intrinsic::riscv_pnclipup: { + bool IsSigned = IntNo == Intrinsic::riscv_pnclipp; + EVT VT = Op.getValueType(); + SDValue Rs1 = Op.getOperand(1); + SDValue Rs2 = Op.getOperand(2); + if (Subtarget.is64Bit()) { + if (VT == MVT::v2i32 && !Rs1.getValueType().isVector()) { + unsigned WOpc = IsSigned ? RISCVISD::PNCLIPP_W : RISCVISD::PNCLIPUP_W; + return DAG.getNode(WOpc, DL, VT, Rs1, Rs2); + } + unsigned Opc = IsSigned ? RISCVISD::PNCLIPP : RISCVISD::PNCLIPUP; + return DAG.getNode(Opc, DL, VT, Rs1, Rs2); + } + + MVT XLenVT = Subtarget.getXLenVT(); + SDValue Shift = DAG.getTargetConstant(0, DL, XLenVT); + if (VT == MVT::v4i8) { + unsigned ClipOpc = IsSigned ? RISCVISD::PNCLIP : RISCVISD::PNCLIPU; + SDValue Pair = DAG.getNode(ISD::CONCAT_VECTORS, DL, MVT::v4i16, Rs1, Rs2); + return DAG.getNode(ClipOpc, DL, VT, Pair, Shift); + } + if (VT == MVT::v2i16) { + unsigned ClipOpc = IsSigned ? RISCVISD::PNCLIP : RISCVISD::PNCLIPU; + SDValue Pair = DAG.getNode(ISD::BUILD_VECTOR, DL, MVT::v2i32, Rs1, Rs2); + return DAG.getNode(ClipOpc, DL, VT, Pair, Shift); + } + if (VT == MVT::v2i32) { + unsigned ClipOpc = IsSigned ? RISCVISD::NCLIP : RISCVISD::NCLIPU; + auto [Rs1Lo, Rs1Hi] = DAG.SplitScalar(Rs1, DL, XLenVT, XLenVT); + auto [Rs2Lo, Rs2Hi] = DAG.SplitScalar(Rs2, DL, XLenVT, XLenVT); + SDValue Lo = DAG.getNode(ClipOpc, DL, XLenVT, Rs1Lo, Rs1Hi, Shift); + SDValue Hi = DAG.getNode(ClipOpc, DL, XLenVT, Rs2Lo, Rs2Hi, Shift); + return DAG.getNode(ISD::BUILD_VECTOR, DL, VT, Lo, Hi); + } + if (VT == MVT::v8i8 || VT == MVT::v4i16) { + unsigned ClipOpc = IsSigned ? RISCVISD::PNCLIP : RISCVISD::PNCLIPU; + MVT HalfVT = VT == MVT::v8i8 ? MVT::v4i8 : MVT::v2i16; + SDValue Lo = DAG.getNode(ClipOpc, DL, HalfVT, Rs1, Shift); + SDValue Hi = DAG.getNode(ClipOpc, DL, HalfVT, Rs2, Shift); + return DAG.getNode(ISD::CONCAT_VECTORS, DL, VT, Lo, Hi); + } + + llvm_unreachable("unexpected VT for pnclipp/pnclipup on RV32"); + } case Intrinsic::riscv_pmulq: case Intrinsic::riscv_pmulqr: { unsigned Opc; @@ -16591,8 +16636,31 @@ void RISCVTargetLowering::ReplaceNodeResults(SDNode *N, Res = DAG.getNode(Opc, DL, WideVT, Ops); else Res = DAG.getNode(Opc, DL, WideVT, ArrayRef(Ops).slice(1)); - Results.push_back(DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, VT, Res, - DAG.getVectorIdxConstant(0, DL))); + Results.push_back(DAG.getExtractSubvector(DL, VT, Res, 0)); + return; + } + case Intrinsic::riscv_pnclipp: + case Intrinsic::riscv_pnclipup: { + bool IsSigned = IntNo == Intrinsic::riscv_pnclipp; + EVT VT = N->getValueType(0); + if (!Subtarget.is64Bit() || (VT != MVT::v4i8 && VT != MVT::v2i16)) + return; + unsigned Opc = IsSigned ? RISCVISD::PNCLIPP : RISCVISD::PNCLIPUP; + SDValue Src1 = N->getOperand(1); + SDValue Src2 = N->getOperand(2); + if (VT == MVT::v4i8) { + MVT WideSrcVT = MVT::v4i16; + SDValue Packed = + DAG.getNode(ISD::CONCAT_VECTORS, DL, WideSrcVT, {Src1, Src2}); + SDValue Res = DAG.getNode(Opc, DL, MVT::v8i8, {Packed, Packed}); + Results.push_back(DAG.getExtractSubvector(DL, VT, Res, 0)); + } else { + MVT WideSrcVT = MVT::v2i32; + SDValue Packed = + DAG.getNode(ISD::BUILD_VECTOR, DL, WideSrcVT, {Src1, Src2}); + SDValue Res = DAG.getNode(Opc, DL, MVT::v4i16, {Packed, Packed}); + Results.push_back(DAG.getExtractSubvector(DL, VT, Res, 0)); + } return; } case Intrinsic::riscv_pssha: diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoP.td b/llvm/lib/Target/RISCV/RISCVInstrInfoP.td index b5cd4c1aad196..f09df843e0c40 100644 --- a/llvm/lib/Target/RISCV/RISCVInstrInfoP.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoP.td @@ -1907,6 +1907,28 @@ def SDT_RISCVPackedNarrowingShift : SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisVec<1>, SDTCisVT<2, XLenVT>]>; def riscv_pnsrl : RVSDNode<"PNSRL", SDT_RISCVPackedNarrowingShift>; +def riscv_pnclip : RVSDNode<"PNCLIP", SDT_RISCVPackedNarrowingShift>; +def riscv_pnclipu : RVSDNode<"PNCLIPU", SDT_RISCVPackedNarrowingShift>; + +// Packed narrowing clip pair. +def SDT_RISCVPackedNarrowingClip + : SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisVec<1>, + SDTCisSameAs<1, 2>]>; +def riscv_pnclipp : RVSDNode<"PNCLIPP", SDT_RISCVPackedNarrowingClip>; +def riscv_pnclipup : RVSDNode<"PNCLIPUP", SDT_RISCVPackedNarrowingClip>; + +def SDT_RISCVNarrowingClip + : SDTypeProfile<1, 3, [SDTCisVT<0, XLenVT>, SDTCisVT<1, XLenVT>, + SDTCisVT<2, XLenVT>, SDTCisVT<3, XLenVT>]>; +def riscv_nclip : RVSDNode<"NCLIP", SDT_RISCVNarrowingClip>; +def riscv_nclipu : RVSDNode<"NCLIPU", SDT_RISCVNarrowingClip>; + +def SDT_RISCVPackedNarrowingClipW + : SDTypeProfile<1, 2, [SDTCisVT<0, v2i32>, + SDTCisVT<1, XLenVT>, + SDTCisSameAs<1, 2>]>; +def riscv_pnclipp_w : RVSDNode<"PNCLIPP_W", SDT_RISCVPackedNarrowingClipW>; +def riscv_pnclipup_w : RVSDNode<"PNCLIPUP_W", SDT_RISCVPackedNarrowingClipW>; // The immediate for these is the number of trailing ones in the max value. def riscv_sati : RVSDNode<"SATI", SDTIntBinOp>; @@ -2631,6 +2653,21 @@ let append Predicates = [IsRV32] in { (EXTRACT_SUBREG GPRPair:$vec, sub_gpr_even)>; def : Pat<(v4i8 (extract_subvector (v8i8 GPRPair:$vec), (i32 4))), (EXTRACT_SUBREG GPRPair:$vec, sub_gpr_odd)>; + + // Packed narrowing clip by immediate (RV32). shift=0 == plain clip. + def : Pat<(v4i8 (riscv_pnclip (v4i16 GPRPair:$rs1), timm:$imm)), + (PNCLIPI_B GPRPair:$rs1, timm:$imm)>; + def : Pat<(v4i8 (riscv_pnclipu (v4i16 GPRPair:$rs1), timm:$imm)), + (PNCLIPIU_B GPRPair:$rs1, timm:$imm)>; + def : Pat<(v2i16 (riscv_pnclip (v2i32 GPRPair:$rs1), timm:$imm)), + (PNCLIPI_H GPRPair:$rs1, timm:$imm)>; + def : Pat<(v2i16 (riscv_pnclipu (v2i32 GPRPair:$rs1), timm:$imm)), + (PNCLIPIU_H GPRPair:$rs1, timm:$imm)>; + + def : Pat<(XLenVT (riscv_nclip XLenVT:$lo, XLenVT:$hi, timm:$imm)), + (NCLIPI (BuildGPRPair GPR:$lo, GPR:$hi), timm:$imm)>; + def : Pat<(XLenVT (riscv_nclipu XLenVT:$lo, XLenVT:$hi, timm:$imm)), + (NCLIPIU (BuildGPRPair GPR:$lo, GPR:$hi), timm:$imm)>; } // append Predicates = [IsRV32] let append Predicates = [IsRV64] in { @@ -2639,6 +2676,20 @@ let append Predicates = [IsRV64] in { def : PatGpr<bitreverse, REV_RV64>; + // Packed narrowing clip pair. + def : Pat<(v8i8 (riscv_pnclipp (v4i16 GPR:$rs1), (v4i16 GPR:$rs2))), + (PNCLIPP_B GPR:$rs1, GPR:$rs2)>; + def : Pat<(v4i16 (riscv_pnclipp (v2i32 GPR:$rs1), (v2i32 GPR:$rs2))), + (PNCLIPP_H GPR:$rs1, GPR:$rs2)>; + def : Pat<(v8i8 (riscv_pnclipup (v4i16 GPR:$rs1), (v4i16 GPR:$rs2))), + (PNCLIPUP_B GPR:$rs1, GPR:$rs2)>; + def : Pat<(v4i16 (riscv_pnclipup (v2i32 GPR:$rs1), (v2i32 GPR:$rs2))), + (PNCLIPUP_H GPR:$rs1, GPR:$rs2)>; + def : Pat<(v2i32 (riscv_pnclipp_w GPR:$rs1, GPR:$rs2)), + (PNCLIPP_W GPR:$rs1, GPR:$rs2)>; + def : Pat<(v2i32 (riscv_pnclipup_w GPR:$rs1, GPR:$rs2)), + (PNCLIPUP_W GPR:$rs1, GPR:$rs2)>; + def : Pat<(XLenVT (riscv_sati GPR:$rs1, timm:$imm)), (SATI_RV64 GPR:$rs1, (IncImm timm:$imm))>; def : Pat<(XLenVT (riscv_usati GPR:$rs1, timm:$imm)), diff --git a/llvm/test/CodeGen/RISCV/rvp-simd-32.ll b/llvm/test/CodeGen/RISCV/rvp-simd-32.ll index 26213eb659e4d..8f96ec6e8a811 100644 --- a/llvm/test/CodeGen/RISCV/rvp-simd-32.ll +++ b/llvm/test/CodeGen/RISCV/rvp-simd-32.ll @@ -2883,3 +2883,71 @@ define <2 x i16> @test_pmulqr_v2i16(<2 x i16> %a, <2 x i16> %b) { %res = call <2 x i16> @llvm.riscv.pmulqr.v2i16(<2 x i16> %a, <2 x i16> %b) ret <2 x i16> %res } + +define <4 x i8> @test_pnclipp_v4i8(<2 x i16> %a, <2 x i16> %b) { +; RV32-LABEL: test_pnclipp_v4i8: +; RV32: # %bb.0: +; RV32-NEXT: pnclipi.b a0, a0, 0 +; RV32-NEXT: ret +; +; RV64-LABEL: test_pnclipp_v4i8: +; RV64: # %bb.0: +; RV64-NEXT: srli a2, a1, 16 +; RV64-NEXT: srli a3, a0, 16 +; RV64-NEXT: ppaire.h a1, a1, a2 +; RV64-NEXT: ppaire.h a0, a0, a3 +; RV64-NEXT: pack a0, a0, a1 +; RV64-NEXT: pnclipp.b a0, a0, a0 +; RV64-NEXT: ret + %r = call <4 x i8> @llvm.riscv.pnclipp.v4i8.v2i16(<2 x i16> %a, <2 x i16> %b) + ret <4 x i8> %r +} + +define <4 x i8> @test_pnclipup_v4i8(<2 x i16> %a, <2 x i16> %b) { +; RV32-LABEL: test_pnclipup_v4i8: +; RV32: # %bb.0: +; RV32-NEXT: pnclipiu.b a0, a0, 0 +; RV32-NEXT: ret +; +; RV64-LABEL: test_pnclipup_v4i8: +; RV64: # %bb.0: +; RV64-NEXT: srli a2, a1, 16 +; RV64-NEXT: srli a3, a0, 16 +; RV64-NEXT: ppaire.h a1, a1, a2 +; RV64-NEXT: ppaire.h a0, a0, a3 +; RV64-NEXT: pack a0, a0, a1 +; RV64-NEXT: pnclipup.b a0, a0, a0 +; RV64-NEXT: ret + %r = call <4 x i8> @llvm.riscv.pnclipup.v4i8.v2i16(<2 x i16> %a, <2 x i16> %b) + ret <4 x i8> %r +} + +define <2 x i16> @test_pnclipp_v2i16(i32 %a, i32 %b) { +; RV32-LABEL: test_pnclipp_v2i16: +; RV32: # %bb.0: +; RV32-NEXT: pnclipi.h a0, a0, 0 +; RV32-NEXT: ret +; +; RV64-LABEL: test_pnclipp_v2i16: +; RV64: # %bb.0: +; RV64-NEXT: pack a0, a0, a1 +; RV64-NEXT: pnclipp.h a0, a0, a0 +; RV64-NEXT: ret + %r = call <2 x i16> @llvm.riscv.pnclipp.v2i16.i32(i32 %a, i32 %b) + ret <2 x i16> %r +} + +define <2 x i16> @test_pnclipup_v2i16(i32 %a, i32 %b) { +; RV32-LABEL: test_pnclipup_v2i16: +; RV32: # %bb.0: +; RV32-NEXT: pnclipiu.h a0, a0, 0 +; RV32-NEXT: ret +; +; RV64-LABEL: test_pnclipup_v2i16: +; RV64: # %bb.0: +; RV64-NEXT: pack a0, a0, a1 +; RV64-NEXT: pnclipup.h a0, a0, a0 +; RV64-NEXT: ret + %r = call <2 x i16> @llvm.riscv.pnclipup.v2i16.i32(i32 %a, i32 %b) + ret <2 x i16> %r +} diff --git a/llvm/test/CodeGen/RISCV/rvp-simd-64.ll b/llvm/test/CodeGen/RISCV/rvp-simd-64.ll index 490634197f29b..fe067d8225fc3 100644 --- a/llvm/test/CodeGen/RISCV/rvp-simd-64.ll +++ b/llvm/test/CodeGen/RISCV/rvp-simd-64.ll @@ -6536,3 +6536,99 @@ define <8 x i8> @test_ppair_v2_used_twice_v8i8(<8 x i8> %a, <8 x i8> %b) { %res = shufflevector <8 x i8> %a, <8 x i8> %b, <8 x i32> <i32 9, i32 8, i32 11, i32 10, i32 13, i32 12, i32 15, i32 14> ret <8 x i8> %res } + +define <8 x i8> @test_pnclipp_v8i8(<4 x i16> %a, <4 x i16> %b) { +; RV32-LABEL: test_pnclipp_v8i8: +; RV32: # %bb.0: +; RV32-NEXT: pnclipi.b a2, a2, 0 +; RV32-NEXT: pnclipi.b a0, a0, 0 +; RV32-NEXT: mv a1, a2 +; RV32-NEXT: ret +; +; RV64-LABEL: test_pnclipp_v8i8: +; RV64: # %bb.0: +; RV64-NEXT: pnclipp.b a0, a0, a1 +; RV64-NEXT: ret + %r = call <8 x i8> @llvm.riscv.pnclipp.v8i8.v4i16(<4 x i16> %a, <4 x i16> %b) + ret <8 x i8> %r +} + +define <8 x i8> @test_pnclipup_v8i8(<4 x i16> %a, <4 x i16> %b) { +; RV32-LABEL: test_pnclipup_v8i8: +; RV32: # %bb.0: +; RV32-NEXT: pnclipiu.b a2, a2, 0 +; RV32-NEXT: pnclipiu.b a0, a0, 0 +; RV32-NEXT: mv a1, a2 +; RV32-NEXT: ret +; +; RV64-LABEL: test_pnclipup_v8i8: +; RV64: # %bb.0: +; RV64-NEXT: pnclipup.b a0, a0, a1 +; RV64-NEXT: ret + %r = call <8 x i8> @llvm.riscv.pnclipup.v8i8.v4i16(<4 x i16> %a, <4 x i16> %b) + ret <8 x i8> %r +} + +define <4 x i16> @test_pnclipp_v4i16(<2 x i32> %a, <2 x i32> %b) { +; RV32-LABEL: test_pnclipp_v4i16: +; RV32: # %bb.0: +; RV32-NEXT: pnclipi.h a2, a2, 0 +; RV32-NEXT: pnclipi.h a0, a0, 0 +; RV32-NEXT: mv a1, a2 +; RV32-NEXT: ret +; +; RV64-LABEL: test_pnclipp_v4i16: +; RV64: # %bb.0: +; RV64-NEXT: pnclipp.h a0, a0, a1 +; RV64-NEXT: ret + %r = call <4 x i16> @llvm.riscv.pnclipp.v4i16.v2i32(<2 x i32> %a, <2 x i32> %b) + ret <4 x i16> %r +} + +define <4 x i16> @test_pnclipup_v4i16(<2 x i32> %a, <2 x i32> %b) { +; RV32-LABEL: test_pnclipup_v4i16: +; RV32: # %bb.0: +; RV32-NEXT: pnclipiu.h a2, a2, 0 +; RV32-NEXT: pnclipiu.h a0, a0, 0 +; RV32-NEXT: mv a1, a2 +; RV32-NEXT: ret +; +; RV64-LABEL: test_pnclipup_v4i16: +; RV64: # %bb.0: +; RV64-NEXT: pnclipup.h a0, a0, a1 +; RV64-NEXT: ret + %r = call <4 x i16> @llvm.riscv.pnclipup.v4i16.v2i32(<2 x i32> %a, <2 x i32> %b) + ret <4 x i16> %r +} + +define i64 @test_pnclipp_v2i32(i64 %a, i64 %b) { +; RV32-LABEL: test_pnclipp_v2i32: +; RV32: # %bb.0: +; RV32-NEXT: nclipi a0, a0, 0 +; RV32-NEXT: nclipi a1, a2, 0 +; RV32-NEXT: ret +; +; RV64-LABEL: test_pnclipp_v2i32: +; RV64: # %bb.0: +; RV64-NEXT: pnclipp.w a0, a0, a1 +; RV64-NEXT: ret + %r = call <2 x i32> @llvm.riscv.pnclipp.v2i32.i64(i64 %a, i64 %b) + %s = bitcast <2 x i32> %r to i64 + ret i64 %s +} + +define i64 @test_pnclipup_v2i32(i64 %a, i64 %b) { +; RV32-LABEL: test_pnclipup_v2i32: +; RV32: # %bb.0: +; RV32-NEXT: nclipiu a0, a0, 0 +; RV32-NEXT: nclipiu a1, a2, 0 +; RV32-NEXT: ret +; +; RV64-LABEL: test_pnclipup_v2i32: +; RV64: # %bb.0: +; RV64-NEXT: pnclipup.w a0, a0, a1 +; RV64-NEXT: ret + %r = call <2 x i32> @llvm.riscv.pnclipup.v2i32.i64(i64 %a, i64 %b) + %s = bitcast <2 x i32> %r to i64 + ret i64 %s +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
