1*207e5cccSFangrui Song // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 2*207e5cccSFangrui Song // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve \ 3*207e5cccSFangrui Song // RUN: -disable-O0-optnone -mvscale-min=4 -mvscale-max=4 \ 4*207e5cccSFangrui Song // RUN: -emit-llvm -o - %s | opt -S -passes=sroa | FileCheck %s 5*207e5cccSFangrui Song 6*207e5cccSFangrui Song // REQUIRES: aarch64-registered-target 7*207e5cccSFangrui Song 8*207e5cccSFangrui Song #include <arm_sve.h> 9*207e5cccSFangrui Song #include <stddef.h> 10*207e5cccSFangrui Song 11*207e5cccSFangrui Song #define N 512 12*207e5cccSFangrui Song 13*207e5cccSFangrui Song typedef svint8_t fixed_int8_t __attribute__((arm_sve_vector_bits(N))); 14*207e5cccSFangrui Song typedef svint16_t fixed_int16_t __attribute__((arm_sve_vector_bits(N))); 15*207e5cccSFangrui Song typedef svint32_t fixed_int32_t __attribute__((arm_sve_vector_bits(N))); 16*207e5cccSFangrui Song typedef svint64_t fixed_int64_t __attribute__((arm_sve_vector_bits(N))); 17*207e5cccSFangrui Song 18*207e5cccSFangrui Song typedef svuint8_t fixed_uint8_t __attribute__((arm_sve_vector_bits(N))); 19*207e5cccSFangrui Song typedef svuint16_t fixed_uint16_t __attribute__((arm_sve_vector_bits(N))); 20*207e5cccSFangrui Song typedef svuint32_t fixed_uint32_t __attribute__((arm_sve_vector_bits(N))); 21*207e5cccSFangrui Song typedef svuint64_t fixed_uint64_t __attribute__((arm_sve_vector_bits(N))); 22*207e5cccSFangrui Song 23*207e5cccSFangrui Song typedef svfloat16_t fixed_float16_t __attribute__((arm_sve_vector_bits(N))); 24*207e5cccSFangrui Song typedef svfloat32_t fixed_float32_t __attribute__((arm_sve_vector_bits(N))); 25*207e5cccSFangrui Song typedef svfloat64_t fixed_float64_t __attribute__((arm_sve_vector_bits(N))); 26*207e5cccSFangrui Song 27*207e5cccSFangrui Song typedef svbool_t fixed_bool_t __attribute__((arm_sve_vector_bits(N))); 28*207e5cccSFangrui Song 29*207e5cccSFangrui Song // CHECK-LABEL: @subscript_int16( 30*207e5cccSFangrui Song // CHECK-NEXT: entry: 31*207e5cccSFangrui Song // CHECK-NEXT: [[A:%.*]] = call <32 x i16> @llvm.vector.extract.v32i16.nxv8i16(<vscale x 8 x i16> [[A_COERCE:%.*]], i64 0) 32*207e5cccSFangrui Song // CHECK-NEXT: [[VECEXT:%.*]] = extractelement <32 x i16> [[A]], i64 [[B:%.*]] 33*207e5cccSFangrui Song // CHECK-NEXT: ret i16 [[VECEXT]] 34*207e5cccSFangrui Song // 35*207e5cccSFangrui Song int16_t subscript_int16(fixed_int16_t a, size_t b) { 36*207e5cccSFangrui Song return a[b]; 37*207e5cccSFangrui Song } 38*207e5cccSFangrui Song 39*207e5cccSFangrui Song // CHECK-LABEL: @subscript_uint16( 40*207e5cccSFangrui Song // CHECK-NEXT: entry: 41*207e5cccSFangrui Song // CHECK-NEXT: [[A:%.*]] = call <32 x i16> @llvm.vector.extract.v32i16.nxv8i16(<vscale x 8 x i16> [[A_COERCE:%.*]], i64 0) 42*207e5cccSFangrui Song // CHECK-NEXT: [[VECEXT:%.*]] = extractelement <32 x i16> [[A]], i64 [[B:%.*]] 43*207e5cccSFangrui Song // CHECK-NEXT: ret i16 [[VECEXT]] 44*207e5cccSFangrui Song // 45*207e5cccSFangrui Song uint16_t subscript_uint16(fixed_uint16_t a, size_t b) { 46*207e5cccSFangrui Song return a[b]; 47*207e5cccSFangrui Song } 48*207e5cccSFangrui Song 49*207e5cccSFangrui Song // CHECK-LABEL: @subscript_int32( 50*207e5cccSFangrui Song // CHECK-NEXT: entry: 51*207e5cccSFangrui Song // CHECK-NEXT: [[A:%.*]] = call <16 x i32> @llvm.vector.extract.v16i32.nxv4i32(<vscale x 4 x i32> [[A_COERCE:%.*]], i64 0) 52*207e5cccSFangrui Song // CHECK-NEXT: [[VECEXT:%.*]] = extractelement <16 x i32> [[A]], i64 [[B:%.*]] 53*207e5cccSFangrui Song // CHECK-NEXT: ret i32 [[VECEXT]] 54*207e5cccSFangrui Song // 55*207e5cccSFangrui Song int32_t subscript_int32(fixed_int32_t a, size_t b) { 56*207e5cccSFangrui Song return a[b]; 57*207e5cccSFangrui Song } 58*207e5cccSFangrui Song 59*207e5cccSFangrui Song // CHECK-LABEL: @subscript_uint32( 60*207e5cccSFangrui Song // CHECK-NEXT: entry: 61*207e5cccSFangrui Song // CHECK-NEXT: [[A:%.*]] = call <16 x i32> @llvm.vector.extract.v16i32.nxv4i32(<vscale x 4 x i32> [[A_COERCE:%.*]], i64 0) 62*207e5cccSFangrui Song // CHECK-NEXT: [[VECEXT:%.*]] = extractelement <16 x i32> [[A]], i64 [[B:%.*]] 63*207e5cccSFangrui Song // CHECK-NEXT: ret i32 [[VECEXT]] 64*207e5cccSFangrui Song // 65*207e5cccSFangrui Song uint32_t subscript_uint32(fixed_uint32_t a, size_t b) { 66*207e5cccSFangrui Song return a[b]; 67*207e5cccSFangrui Song } 68*207e5cccSFangrui Song 69*207e5cccSFangrui Song // CHECK-LABEL: @subscript_int64( 70*207e5cccSFangrui Song // CHECK-NEXT: entry: 71*207e5cccSFangrui Song // CHECK-NEXT: [[A:%.*]] = call <8 x i64> @llvm.vector.extract.v8i64.nxv2i64(<vscale x 2 x i64> [[A_COERCE:%.*]], i64 0) 72*207e5cccSFangrui Song // CHECK-NEXT: [[VECEXT:%.*]] = extractelement <8 x i64> [[A]], i64 [[B:%.*]] 73*207e5cccSFangrui Song // CHECK-NEXT: ret i64 [[VECEXT]] 74*207e5cccSFangrui Song // 75*207e5cccSFangrui Song int64_t subscript_int64(fixed_int64_t a, size_t b) { 76*207e5cccSFangrui Song return a[b]; 77*207e5cccSFangrui Song } 78*207e5cccSFangrui Song 79*207e5cccSFangrui Song // CHECK-LABEL: @subscript_uint64( 80*207e5cccSFangrui Song // CHECK-NEXT: entry: 81*207e5cccSFangrui Song // CHECK-NEXT: [[A:%.*]] = call <8 x i64> @llvm.vector.extract.v8i64.nxv2i64(<vscale x 2 x i64> [[A_COERCE:%.*]], i64 0) 82*207e5cccSFangrui Song // CHECK-NEXT: [[VECEXT:%.*]] = extractelement <8 x i64> [[A]], i64 [[B:%.*]] 83*207e5cccSFangrui Song // CHECK-NEXT: ret i64 [[VECEXT]] 84*207e5cccSFangrui Song // 85*207e5cccSFangrui Song uint64_t subscript_uint64(fixed_uint64_t a, size_t b) { 86*207e5cccSFangrui Song return a[b]; 87*207e5cccSFangrui Song } 88*207e5cccSFangrui Song 89*207e5cccSFangrui Song // CHECK-LABEL: @subscript_float16( 90*207e5cccSFangrui Song // CHECK-NEXT: entry: 91*207e5cccSFangrui Song // CHECK-NEXT: [[A:%.*]] = call <32 x half> @llvm.vector.extract.v32f16.nxv8f16(<vscale x 8 x half> [[A_COERCE:%.*]], i64 0) 92*207e5cccSFangrui Song // CHECK-NEXT: [[VECEXT:%.*]] = extractelement <32 x half> [[A]], i64 [[B:%.*]] 93*207e5cccSFangrui Song // CHECK-NEXT: ret half [[VECEXT]] 94*207e5cccSFangrui Song // 95*207e5cccSFangrui Song __fp16 subscript_float16(fixed_float16_t a, size_t b) { 96*207e5cccSFangrui Song return a[b]; 97*207e5cccSFangrui Song } 98*207e5cccSFangrui Song 99*207e5cccSFangrui Song // CHECK-LABEL: @subscript_float32( 100*207e5cccSFangrui Song // CHECK-NEXT: entry: 101*207e5cccSFangrui Song // CHECK-NEXT: [[A:%.*]] = call <16 x float> @llvm.vector.extract.v16f32.nxv4f32(<vscale x 4 x float> [[A_COERCE:%.*]], i64 0) 102*207e5cccSFangrui Song // CHECK-NEXT: [[VECEXT:%.*]] = extractelement <16 x float> [[A]], i64 [[B:%.*]] 103*207e5cccSFangrui Song // CHECK-NEXT: ret float [[VECEXT]] 104*207e5cccSFangrui Song // 105*207e5cccSFangrui Song float subscript_float32(fixed_float32_t a, size_t b) { 106*207e5cccSFangrui Song return a[b]; 107*207e5cccSFangrui Song } 108*207e5cccSFangrui Song 109*207e5cccSFangrui Song // CHECK-LABEL: @subscript_float64( 110*207e5cccSFangrui Song // CHECK-NEXT: entry: 111*207e5cccSFangrui Song // CHECK-NEXT: [[A:%.*]] = call <8 x double> @llvm.vector.extract.v8f64.nxv2f64(<vscale x 2 x double> [[A_COERCE:%.*]], i64 0) 112*207e5cccSFangrui Song // CHECK-NEXT: [[VECEXT:%.*]] = extractelement <8 x double> [[A]], i64 [[B:%.*]] 113*207e5cccSFangrui Song // CHECK-NEXT: ret double [[VECEXT]] 114*207e5cccSFangrui Song // 115*207e5cccSFangrui Song double subscript_float64(fixed_float64_t a, size_t b) { 116*207e5cccSFangrui Song return a[b]; 117*207e5cccSFangrui Song } 118