llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang @llvm/pr-subscribers-clangir Author: Andy Kaylor (andykaylor) <details> <summary>Changes</summary> This fixes a problem with vector splat cast handling. We had been asserting that the AST destination type was a vector type, but it can also be a builtin SVE type. I have replaced this with an assert on the converted destination type. Builtin SVE types are converted to scalable vector CIR types. Test updates assisted by Cursor. --- Patch is 46.87 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/232896.diff 2 Files Affected: - (modified) clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp (+4-2) - (modified) clang/test/CIR/CodeGen/sve-vector-arith-ops.c (+983) ``````````diff diff --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp index c27f7ef7417e5..2082963025238 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp @@ -2922,10 +2922,12 @@ mlir::Value ScalarExprEmitter::VisitCastExpr(CastExpr *ce) { case CK_VectorSplat: { // Create a vector object and fill all elements with the same scalar value. - assert(destTy->isVectorType() && "CK_VectorSplat to non-vector type"); + mlir::Type destCIRTy = cgf.convertType(destTy); + assert(mlir::isa<cir::VectorType>(destCIRTy) && + "CK_VectorSplat to non-vector type"); return cir::VecSplatOp::create(builder, cgf.getLoc(subExpr->getSourceRange()), - cgf.convertType(destTy), Visit(subExpr)); + destCIRTy, Visit(subExpr)); } case CK_FunctionToPointerDecay: return cgf.emitLValue(subExpr).getPointer(); diff --git a/clang/test/CIR/CodeGen/sve-vector-arith-ops.c b/clang/test/CIR/CodeGen/sve-vector-arith-ops.c index 9b9275160964d..1b02637e601cf 100644 --- a/clang/test/CIR/CodeGen/sve-vector-arith-ops.c +++ b/clang/test/CIR/CodeGen/sve-vector-arith-ops.c @@ -280,6 +280,374 @@ svfloat64_t add_inplace_f64(svfloat64_t a, svfloat64_t b) { return a += b; } +// CIR-LABEL: cir.func {{.*}} @add_scalar_i8( +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !s8i, !cir.vector<[16] x !s8i> +// CIR: {{%.*}} = cir.add {{%.*}}, {{%.*}} : !cir.vector<[16] x !s8i> + +// LLVM-LABEL: @add_scalar_i8( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[SPLAT_SPLATINSERT:%.*]] = insertelement <vscale x 16 x i8> poison, i8 [[B:%.*]], i64 0 +// LLVM-NEXT: [[SPLAT_SPLAT:%.*]] = shufflevector <vscale x 16 x i8> [[SPLAT_SPLATINSERT]], <vscale x 16 x i8> poison, <vscale x 16 x i32> zeroinitializer +// LLVM-NEXT: [[ADD:%.*]] = add <vscale x 16 x i8> [[A:%.*]], [[SPLAT_SPLAT]] +// LLVM-NEXT: ret <vscale x 16 x i8> [[ADD]] +// +svint8_t add_scalar_i8(svint8_t a, int8_t b) { + return a + b; +} + +// CIR-LABEL: cir.func {{.*}} @add_scalar_i16( +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !s16i, !cir.vector<[8] x !s16i> +// CIR: {{%.*}} = cir.add {{%.*}}, {{%.*}} : !cir.vector<[8] x !s16i> + +// LLVM-LABEL: @add_scalar_i16( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[SPLAT_SPLATINSERT:%.*]] = insertelement <vscale x 8 x i16> poison, i16 [[B:%.*]], i64 0 +// LLVM-NEXT: [[SPLAT_SPLAT:%.*]] = shufflevector <vscale x 8 x i16> [[SPLAT_SPLATINSERT]], <vscale x 8 x i16> poison, <vscale x 8 x i32> zeroinitializer +// LLVM-NEXT: [[ADD:%.*]] = add <vscale x 8 x i16> [[A:%.*]], [[SPLAT_SPLAT]] +// LLVM-NEXT: ret <vscale x 8 x i16> [[ADD]] +// +svint16_t add_scalar_i16(svint16_t a, int16_t b) { + return a + b; +} + +// CIR-LABEL: cir.func {{.*}} @add_scalar_i32( +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !s32i, !cir.vector<[4] x !s32i> +// CIR: {{%.*}} = cir.add {{%.*}}, {{%.*}} : !cir.vector<[4] x !s32i> + +// LLVM-LABEL: @add_scalar_i32( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[SPLAT_SPLATINSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[B:%.*]], i64 0 +// LLVM-NEXT: [[SPLAT_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[SPLAT_SPLATINSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer +// LLVM-NEXT: [[ADD:%.*]] = add <vscale x 4 x i32> [[A:%.*]], [[SPLAT_SPLAT]] +// LLVM-NEXT: ret <vscale x 4 x i32> [[ADD]] +// +svint32_t add_scalar_i32(svint32_t a, int32_t b) { + return a + b; +} + +// CIR-LABEL: cir.func {{.*}} @add_scalar_i64( +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !s64i, !cir.vector<[2] x !s64i> +// CIR: {{%.*}} = cir.add {{%.*}}, {{%.*}} : !cir.vector<[2] x !s64i> + +// LLVM-LABEL: @add_scalar_i64( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[SPLAT_SPLATINSERT:%.*]] = insertelement <vscale x 2 x i64> poison, i64 [[B:%.*]], i64 0 +// LLVM-NEXT: [[SPLAT_SPLAT:%.*]] = shufflevector <vscale x 2 x i64> [[SPLAT_SPLATINSERT]], <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer +// LLVM-NEXT: [[ADD:%.*]] = add <vscale x 2 x i64> [[A:%.*]], [[SPLAT_SPLAT]] +// LLVM-NEXT: ret <vscale x 2 x i64> [[ADD]] +// +svint64_t add_scalar_i64(svint64_t a, int64_t b) { + return a + b; +} + +// CIR-LABEL: cir.func {{.*}} @add_scalar_u8( +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !u8i, !cir.vector<[16] x !u8i> +// CIR: {{%.*}} = cir.add {{%.*}}, {{%.*}} : !cir.vector<[16] x !u8i> + +// LLVM-LABEL: @add_scalar_u8( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[SPLAT_SPLATINSERT:%.*]] = insertelement <vscale x 16 x i8> poison, i8 [[B:%.*]], i64 0 +// LLVM-NEXT: [[SPLAT_SPLAT:%.*]] = shufflevector <vscale x 16 x i8> [[SPLAT_SPLATINSERT]], <vscale x 16 x i8> poison, <vscale x 16 x i32> zeroinitializer +// LLVM-NEXT: [[ADD:%.*]] = add <vscale x 16 x i8> [[A:%.*]], [[SPLAT_SPLAT]] +// LLVM-NEXT: ret <vscale x 16 x i8> [[ADD]] +// +svuint8_t add_scalar_u8(svuint8_t a, uint8_t b) { + return a + b; +} + +// CIR-LABEL: cir.func {{.*}} @add_scalar_u16( +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !u16i, !cir.vector<[8] x !u16i> +// CIR: {{%.*}} = cir.add {{%.*}}, {{%.*}} : !cir.vector<[8] x !u16i> + +// LLVM-LABEL: @add_scalar_u16( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[SPLAT_SPLATINSERT:%.*]] = insertelement <vscale x 8 x i16> poison, i16 [[B:%.*]], i64 0 +// LLVM-NEXT: [[SPLAT_SPLAT:%.*]] = shufflevector <vscale x 8 x i16> [[SPLAT_SPLATINSERT]], <vscale x 8 x i16> poison, <vscale x 8 x i32> zeroinitializer +// LLVM-NEXT: [[ADD:%.*]] = add <vscale x 8 x i16> [[A:%.*]], [[SPLAT_SPLAT]] +// LLVM-NEXT: ret <vscale x 8 x i16> [[ADD]] +// +svuint16_t add_scalar_u16(svuint16_t a, uint16_t b) { + return a + b; +} + +// CIR-LABEL: cir.func {{.*}} @add_scalar_u32( +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !u32i, !cir.vector<[4] x !u32i> +// CIR: {{%.*}} = cir.add {{%.*}}, {{%.*}} : !cir.vector<[4] x !u32i> + +// LLVM-LABEL: @add_scalar_u32( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[SPLAT_SPLATINSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[B:%.*]], i64 0 +// LLVM-NEXT: [[SPLAT_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[SPLAT_SPLATINSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer +// LLVM-NEXT: [[ADD:%.*]] = add <vscale x 4 x i32> [[A:%.*]], [[SPLAT_SPLAT]] +// LLVM-NEXT: ret <vscale x 4 x i32> [[ADD]] +// +svuint32_t add_scalar_u32(svuint32_t a, uint32_t b) { + return a + b; +} + +// CIR-LABEL: cir.func {{.*}} @add_scalar_u64( +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !u64i, !cir.vector<[2] x !u64i> +// CIR: {{%.*}} = cir.add {{%.*}}, {{%.*}} : !cir.vector<[2] x !u64i> + +// LLVM-LABEL: @add_scalar_u64( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[SPLAT_SPLATINSERT:%.*]] = insertelement <vscale x 2 x i64> poison, i64 [[B:%.*]], i64 0 +// LLVM-NEXT: [[SPLAT_SPLAT:%.*]] = shufflevector <vscale x 2 x i64> [[SPLAT_SPLATINSERT]], <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer +// LLVM-NEXT: [[ADD:%.*]] = add <vscale x 2 x i64> [[A:%.*]], [[SPLAT_SPLAT]] +// LLVM-NEXT: ret <vscale x 2 x i64> [[ADD]] +// +svuint64_t add_scalar_u64(svuint64_t a, uint64_t b) { + return a + b; +} + +// CIR-LABEL: cir.func {{.*}} @add_scalar_f16( +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !cir.f16, !cir.vector<[8] x !cir.f16> +// CIR: {{%.*}} = cir.fadd {{%.*}}, {{%.*}} : !cir.vector<[8] x !cir.f16> + +// LLVM-LABEL: @add_scalar_f16( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[SPLAT_SPLATINSERT:%.*]] = insertelement <vscale x 8 x half> poison, half [[B:%.*]], i64 0 +// LLVM-NEXT: [[SPLAT_SPLAT:%.*]] = shufflevector <vscale x 8 x half> [[SPLAT_SPLATINSERT]], <vscale x 8 x half> poison, <vscale x 8 x i32> zeroinitializer +// LLVM-NEXT: [[ADD:%.*]] = fadd <vscale x 8 x half> [[A:%.*]], [[SPLAT_SPLAT]] +// LLVM-NEXT: ret <vscale x 8 x half> [[ADD]] +// +svfloat16_t add_scalar_f16(svfloat16_t a, __fp16 b) { + return a + b; +} + +// CIR-LABEL: cir.func {{.*}} @add_scalar_f32( +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !cir.float, !cir.vector<[4] x !cir.float> +// CIR: {{%.*}} = cir.fadd {{%.*}}, {{%.*}} : !cir.vector<[4] x !cir.float> + +// LLVM-LABEL: @add_scalar_f32( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[SPLAT_SPLATINSERT:%.*]] = insertelement <vscale x 4 x float> poison, float [[B:%.*]], i64 0 +// LLVM-NEXT: [[SPLAT_SPLAT:%.*]] = shufflevector <vscale x 4 x float> [[SPLAT_SPLATINSERT]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer +// LLVM-NEXT: [[ADD:%.*]] = fadd <vscale x 4 x float> [[A:%.*]], [[SPLAT_SPLAT]] +// LLVM-NEXT: ret <vscale x 4 x float> [[ADD]] +// +svfloat32_t add_scalar_f32(svfloat32_t a, float b) { + return a + b; +} + +// CIR-LABEL: cir.func {{.*}} @add_scalar_f64( +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !cir.double, !cir.vector<[2] x !cir.double> +// CIR: {{%.*}} = cir.fadd {{%.*}}, {{%.*}} : !cir.vector<[2] x !cir.double> + +// LLVM-LABEL: @add_scalar_f64( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[SPLAT_SPLATINSERT:%.*]] = insertelement <vscale x 2 x double> poison, double [[B:%.*]], i64 0 +// LLVM-NEXT: [[SPLAT_SPLAT:%.*]] = shufflevector <vscale x 2 x double> [[SPLAT_SPLATINSERT]], <vscale x 2 x double> poison, <vscale x 2 x i32> zeroinitializer +// LLVM-NEXT: [[ADD:%.*]] = fadd <vscale x 2 x double> [[A:%.*]], [[SPLAT_SPLAT]] +// LLVM-NEXT: ret <vscale x 2 x double> [[ADD]] +// +svfloat64_t add_scalar_f64(svfloat64_t a, double b) { + return a + b; +} + +// CIR-LABEL: cir.func {{.*}} @add_i8_i_lit( +// CIR: {{%.*}} = cir.const #cir.int<0> : !s8i +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !s8i, !cir.vector<[16] x !s8i> +// CIR: {{%.*}} = cir.add {{%.*}}, {{%.*}} : !cir.vector<[16] x !s8i> + +// LLVM-LABEL: @add_i8_i_lit( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[ADD:%.*]] = add <vscale x 16 x i8> [[A:%.*]], zeroinitializer +// LLVM-NEXT: ret <vscale x 16 x i8> [[ADD]] +// +svint8_t add_i8_i_lit(svint8_t a) { + return a + 0; +} + +// CIR-LABEL: cir.func {{.*}} @add_i8_il_lit( +// CIR: {{%.*}} = cir.const #cir.int<0> : !s8i +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !s8i, !cir.vector<[16] x !s8i> +// CIR: {{%.*}} = cir.add {{%.*}}, {{%.*}} : !cir.vector<[16] x !s8i> + +// LLVM-LABEL: @add_i8_il_lit( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[ADD:%.*]] = add <vscale x 16 x i8> [[A:%.*]], zeroinitializer +// LLVM-NEXT: ret <vscale x 16 x i8> [[ADD]] +// +svint8_t add_i8_il_lit(svint8_t a) { + return a + 0l; +} + +// CIR-LABEL: cir.func {{.*}} @add_i8_ill_lit( +// CIR: {{%.*}} = cir.const #cir.int<0> : !s8i +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !s8i, !cir.vector<[16] x !s8i> +// CIR: {{%.*}} = cir.add {{%.*}}, {{%.*}} : !cir.vector<[16] x !s8i> + +// LLVM-LABEL: @add_i8_ill_lit( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[ADD:%.*]] = add <vscale x 16 x i8> [[A:%.*]], zeroinitializer +// LLVM-NEXT: ret <vscale x 16 x i8> [[ADD]] +// +svint8_t add_i8_ill_lit(svint8_t a) { + return a + 0ll; +} + +// CIR-LABEL: cir.func {{.*}} @add_i8_u_lit( +// CIR: {{%.*}} = cir.const #cir.int<0> : !s8i +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !s8i, !cir.vector<[16] x !s8i> +// CIR: {{%.*}} = cir.add {{%.*}}, {{%.*}} : !cir.vector<[16] x !s8i> + +// LLVM-LABEL: @add_i8_u_lit( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[ADD:%.*]] = add <vscale x 16 x i8> [[A:%.*]], zeroinitializer +// LLVM-NEXT: ret <vscale x 16 x i8> [[ADD]] +// +svint8_t add_i8_u_lit(svint8_t a) { + return a + 0u; +} + +// CIR-LABEL: cir.func {{.*}} @add_i8_ul_lit( +// CIR: {{%.*}} = cir.const #cir.int<0> : !s8i +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !s8i, !cir.vector<[16] x !s8i> +// CIR: {{%.*}} = cir.add {{%.*}}, {{%.*}} : !cir.vector<[16] x !s8i> + +// LLVM-LABEL: @add_i8_ul_lit( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[ADD:%.*]] = add <vscale x 16 x i8> [[A:%.*]], zeroinitializer +// LLVM-NEXT: ret <vscale x 16 x i8> [[ADD]] +// +svint8_t add_i8_ul_lit(svint8_t a) { + return a + 0ul; +} + +// CIR-LABEL: cir.func {{.*}} @add_i8_ull_lit( +// CIR: {{%.*}} = cir.const #cir.int<0> : !s8i +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !s8i, !cir.vector<[16] x !s8i> +// CIR: {{%.*}} = cir.add {{%.*}}, {{%.*}} : !cir.vector<[16] x !s8i> + +// LLVM-LABEL: @add_i8_ull_lit( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[ADD:%.*]] = add <vscale x 16 x i8> [[A:%.*]], zeroinitializer +// LLVM-NEXT: ret <vscale x 16 x i8> [[ADD]] +// +svint8_t add_i8_ull_lit(svint8_t a) { + return a + 0ull; +} + +// CIR-LABEL: cir.func {{.*}} @add_f64_i_lit( +// CIR: {{%.*}} = cir.const #cir.int<0> : !s32i +// CIR: {{%.*}} = cir.cast int_to_float {{%.*}} : !s32i -> !cir.double +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !cir.double, !cir.vector<[2] x !cir.double> +// CIR: {{%.*}} = cir.fadd {{%.*}}, {{%.*}} : !cir.vector<[2] x !cir.double> + +// LLVM-LABEL: @add_f64_i_lit( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[ADD:%.*]] = fadd <vscale x 2 x double> [[A:%.*]], zeroinitializer +// LLVM-NEXT: ret <vscale x 2 x double> [[ADD]] +// +svfloat64_t add_f64_i_lit(svfloat64_t a) { + return a + 0; +} + +// CIR-LABEL: cir.func {{.*}} @add_f64_il_lit( +// CIR: {{%.*}} = cir.const #cir.int<0> : !s64i +// CIR: {{%.*}} = cir.cast int_to_float {{%.*}} : !s64i -> !cir.double +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !cir.double, !cir.vector<[2] x !cir.double> +// CIR: {{%.*}} = cir.fadd {{%.*}}, {{%.*}} : !cir.vector<[2] x !cir.double> + +// LLVM-LABEL: @add_f64_il_lit( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[ADD:%.*]] = fadd <vscale x 2 x double> [[A:%.*]], zeroinitializer +// LLVM-NEXT: ret <vscale x 2 x double> [[ADD]] +// +svfloat64_t add_f64_il_lit(svfloat64_t a) { + return a + 0l; +} + +// CIR-LABEL: cir.func {{.*}} @add_f64_ill_lit( +// CIR: {{%.*}} = cir.const #cir.int<0> : !s64i +// CIR: {{%.*}} = cir.cast int_to_float {{%.*}} : !s64i -> !cir.double +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !cir.double, !cir.vector<[2] x !cir.double> +// CIR: {{%.*}} = cir.fadd {{%.*}}, {{%.*}} : !cir.vector<[2] x !cir.double> + +// LLVM-LABEL: @add_f64_ill_lit( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[ADD:%.*]] = fadd <vscale x 2 x double> [[A:%.*]], zeroinitializer +// LLVM-NEXT: ret <vscale x 2 x double> [[ADD]] +// +svfloat64_t add_f64_ill_lit(svfloat64_t a) { + return a + 0ll; +} + +// CIR-LABEL: cir.func {{.*}} @add_f64_u_lit( +// CIR: {{%.*}} = cir.const #cir.int<0> : !u32i +// CIR: {{%.*}} = cir.cast int_to_float {{%.*}} : !u32i -> !cir.double +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !cir.double, !cir.vector<[2] x !cir.double> +// CIR: {{%.*}} = cir.fadd {{%.*}}, {{%.*}} : !cir.vector<[2] x !cir.double> + +// LLVM-LABEL: @add_f64_u_lit( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[ADD:%.*]] = fadd <vscale x 2 x double> [[A:%.*]], zeroinitializer +// LLVM-NEXT: ret <vscale x 2 x double> [[ADD]] +// +svfloat64_t add_f64_u_lit(svfloat64_t a) { + return a + 0u; +} + +// CIR-LABEL: cir.func {{.*}} @add_f64_ul_lit( +// CIR: {{%.*}} = cir.const #cir.int<0> : !u64i +// CIR: {{%.*}} = cir.cast int_to_float {{%.*}} : !u64i -> !cir.double +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !cir.double, !cir.vector<[2] x !cir.double> +// CIR: {{%.*}} = cir.fadd {{%.*}}, {{%.*}} : !cir.vector<[2] x !cir.double> + +// LLVM-LABEL: @add_f64_ul_lit( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[ADD:%.*]] = fadd <vscale x 2 x double> [[A:%.*]], zeroinitializer +// LLVM-NEXT: ret <vscale x 2 x double> [[ADD]] + +svfloat64_t add_f64_ul_lit(svfloat64_t a) { + return a + 0ul; +} + +// CIR-LABEL: cir.func {{.*}} @add_f64_ull_lit( +// CIR: {{%.*}} = cir.const #cir.int<0> : !u64i +// CIR: {{%.*}} = cir.cast int_to_float {{%.*}} : !u64i -> !cir.double +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !cir.double, !cir.vector<[2] x !cir.double> +// CIR: {{%.*}} = cir.fadd {{%.*}}, {{%.*}} : !cir.vector<[2] x !cir.double> + +// LLVM-LABEL: @add_f64_ull_lit( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[ADD:%.*]] = fadd <vscale x 2 x double> [[A:%.*]], zeroinitializer +// LLVM-NEXT: ret <vscale x 2 x double> [[ADD]] + +svfloat64_t add_f64_ull_lit(svfloat64_t a) { + return a + 0ull; +} + +// CIR-LABEL: cir.func {{.*}} @add_f64_f_lit( +// CIR: {{%.*}} = cir.const #cir.fp<0.000000e+00> : !cir.float +// CIR: {{%.*}} = cir.cast floating {{%.*}} : !cir.float -> !cir.double +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !cir.double, !cir.vector<[2] x !cir.double> +// CIR: {{%.*}} = cir.fadd {{%.*}}, {{%.*}} : !cir.vector<[2] x !cir.double> + +// LLVM-LABEL: @add_f64_f_lit( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[ADD:%.*]] = fadd <vscale x 2 x double> [[A:%.*]], zeroinitializer +// LLVM-NEXT: ret <vscale x 2 x double> [[ADD]] +// +svfloat64_t add_f64_f_lit(svfloat64_t a) { + return a + 0.f; +} + +// CIR-LABEL: cir.func {{.*}} @add_f64_d_lit( +// CIR: {{%.*}} = cir.const #cir.fp<0.000000e+00> : !cir.double +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !cir.double, !cir.vector<[2] x !cir.double> +// CIR: {{%.*}} = cir.fadd {{%.*}}, {{%.*}} : !cir.vector<[2] x !cir.double> + +// LLVM-LABEL: @add_f64_d_lit( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[ADD:%.*]] = fadd <vscale x 2 x double> [[A:%.*]], zeroinitializer +// LLVM-NEXT: ret <vscale x 2 x double> [[ADD]] +// +svfloat64_t add_f64_d_lit(svfloat64_t a) { + return a + 0.; +} + // SUBTRACTION // CIR-LABEL: cir.func {{.*}} @sub_i8( @@ -546,6 +914,171 @@ svfloat64_t sub_inplace_f64(svfloat64_t a, svfloat64_t b) { return a - b; } +// CIR-LABEL: cir.func {{.*}} @sub_scalar_i8( +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !s8i, !cir.vector<[16] x !s8i> +// CIR: {{%.*}} = cir.sub {{%.*}}, {{%.*}} : !cir.vector<[16] x !s8i> + +// LLVM-LABEL: @sub_scalar_i8( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[SPLAT_SPLATINSERT:%.*]] = insertelement <vscale x 16 x i8> poison, i8 [[B:%.*]], i64 0 +// LLVM-NEXT: [[SPLAT_SPLAT:%.*]] = shufflevector <vscale x 16 x i8> [[SPLAT_SPLATINSERT]], <vscale x 16 x i8> poison, <vscale x 16 x i32> zeroinitializer +// LLVM-NEXT: [[SUB:%.*]] = sub <vscale x 16 x i8> [[A:%.*]], [[SPLAT_SPLAT]] +// LLVM-NEXT: ret <vscale x 16 x i8> [[SUB]] +// +svint8_t sub_scalar_i8(svint8_t a, int8_t b) { + return a - b; +} + +// CIR-LABEL: cir.func {{.*}} @sub_scalar_i16( +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !s16i, !cir.vector<[8] x !s16i> +// CIR: {{%.*}} = cir.sub {{%.*}}, {{%.*}} : !cir.vector<[8] x !s16i> + +// LLVM-LABEL: @sub_scalar_i16( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[SPLAT_SPLATINSERT:%.*]] = insertelement <vscale x 8 x i16> poison, i16 [[B:%.*]], i64 0 +// LLVM-NEXT: [[SPLAT_SPLAT:%.*]] = shufflevector <vscale x 8 x i16> [[SPLAT_SPLATINSERT]], <vscale x 8 x i16> poison, <vscale x 8 x i32> zeroinitializer +// LLVM-NEXT: [[SUB:%.*]] = sub <vscale x 8 x i16> [[A:%.*]], [[SPLAT_SPLAT]] +// LLVM-NEXT: ret <vscale x 8 x i16> [[SUB]] +// +svint16_t sub_scalar_i16(svint16_t a, int16_t b) { + return a - b; +} + +// CIR-LABEL: cir.func {{.*}} @sub_scalar_i32( +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !s32i, !cir.vector<[4] x !s32i> +// CIR: {{%.*}} = cir.sub {{%.*}}, {{%.*}} : !cir.vector<[4] x !s32i> + +// LLVM-LABEL: @sub_scalar_i32( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[SPLAT_SPLATINSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[B:%.*]], i64 0 +// LLVM-NEXT: [[SPLAT_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[SPLAT_SPLATINSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer +// LLVM-NEXT: [[SUB:%.*]] = sub <vscale x 4 x i32> [[A:%.*]], [[SPLAT_SPLAT]] +// LLVM-NEXT: ret <vscale x 4 x i32> [[SUB]] +// +svint32_t sub_scalar_i32(svint32_t a, int32_t b) { + return a - b; +} + +// CIR-LABEL: cir.func {{.*}} @sub_scalar_i64( +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !s64i, !cir.vector<[2] x !s64i> +// CIR: {{%.*}} = cir.sub {{%.*}}, {{%.*}} : !cir.vector<[2] x !s64i> + +// LLVM-LABEL: @sub_scalar_i64( +// OGCG-NEXT: entry: +// LLVM-NEXT: [[SPLAT_SPLATINSERT:%.*]] = insertelement <vscale x 2 x i64> poison, i64 [[B:%.*]], i64 0 +// LLVM-NEXT: [[SPLAT_SPLAT:%.*]] = shufflevector <vscale x 2 x i64> [[SPLAT_SPLATINSERT]], <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer +// LLVM-NEXT: [[SUB:%.*]] = sub <vscale x 2 x i64> [[A:%.*]], [[SPLAT_SPLAT]] +// LLVM-NEXT: ret <vscale x 2 x i64> [[SUB]] +// +svint64_t sub_scalar_i64(svint64_t a, int64_t b) { + return a - b; +} + +// CIR-LABEL: cir.func {{.*}} @sub_scalar_u8( +// CIR: {{%.*}} = cir.vec.splat {{%.*}} : !u8i, !cir.vector<[16] x !u8i> +// CIR: {{%.*}} = cir.sub {{%.*}}, {{%.*}} : !cir.vector<[16] x !u8i> + +// LLVM-LABEL: @sub_scalar_... [truncated] `````````` </details> https://github.com/llvm/llvm-project/pull/232896 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
