llvm-project/clang/test/CodeGen/aarch64-sve-vector-subscript-ops.c
David Green 123064dc39 [Clang][Arm] Convert -fallow-half-arguments-and-returns to a target option. NFC
This cc1 option -fallow-half-arguments-and-returns allows __fp16 to be
passed by argument and returned, without giving an error. It is
currently always enabled for Arm and AArch64, by forcing the option in
the driver. This means any cc1 tests (especially those needing
arm_neon.h) need to specify the option too, to prevent the error from
being emitted.

This changes it to a target option instead, set to true for Arm and
AArch64. This allows the option to be removed. Previously it was implied
by -fnative_half_arguments_and_returns, which is set for certain
languages like open_cl, renderscript and hlsl, so that option now too
controls the errors. There were are few other non-arm uses of
-fallow-half-arguments-and-returns but I believe they were unnecessary.
The strictfp_builtins.c tests were converted from __fp16 to _Float16 to
avoid the issues.

Differential Revision: https://reviews.llvm.org/D133885
2022-09-29 11:00:32 +01:00

91 lines
2.6 KiB
C

// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve \
// RUN: -disable-O0-optnone \
// RUN: -emit-llvm -o - %s | opt -S -sroa | FileCheck %s
// REQUIRES: aarch64-registered-target
#include <arm_sve.h>
#include <stddef.h>
// CHECK-LABEL: @subscript_int16(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[VECEXT:%.*]] = extractelement <vscale x 8 x i16> [[A:%.*]], i64 [[B:%.*]]
// CHECK-NEXT: ret i16 [[VECEXT]]
//
int16_t subscript_int16(svint16_t a, size_t b) {
return a[b];
}
// CHECK-LABEL: @subscript_uint16(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[VECEXT:%.*]] = extractelement <vscale x 8 x i16> [[A:%.*]], i64 [[B:%.*]]
// CHECK-NEXT: ret i16 [[VECEXT]]
//
uint16_t subscript_uint16(svuint16_t a, size_t b) {
return a[b];
}
// CHECK-LABEL: @subscript_int32(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[VECEXT:%.*]] = extractelement <vscale x 4 x i32> [[A:%.*]], i64 [[B:%.*]]
// CHECK-NEXT: ret i32 [[VECEXT]]
//
int32_t subscript_int32(svint32_t a, size_t b) {
return a[b];
}
// CHECK-LABEL: @subscript_uint32(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[VECEXT:%.*]] = extractelement <vscale x 4 x i32> [[A:%.*]], i64 [[B:%.*]]
// CHECK-NEXT: ret i32 [[VECEXT]]
//
uint32_t subscript_uint32(svuint32_t a, size_t b) {
return a[b];
}
// CHECK-LABEL: @subscript_int64(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[VECEXT:%.*]] = extractelement <vscale x 2 x i64> [[A:%.*]], i64 [[B:%.*]]
// CHECK-NEXT: ret i64 [[VECEXT]]
//
int64_t subscript_int64(svint64_t a, size_t b) {
return a[b];
}
// CHECK-LABEL: @subscript_uint64(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[VECEXT:%.*]] = extractelement <vscale x 2 x i64> [[A:%.*]], i64 [[B:%.*]]
// CHECK-NEXT: ret i64 [[VECEXT]]
//
uint64_t subscript_uint64(svuint64_t a, size_t b) {
return a[b];
}
// CHECK-LABEL: @subscript_float16(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[VECEXT:%.*]] = extractelement <vscale x 8 x half> [[A:%.*]], i64 [[B:%.*]]
// CHECK-NEXT: ret half [[VECEXT]]
//
__fp16 subscript_float16(svfloat16_t a, size_t b) {
return a[b];
}
// CHECK-LABEL: @subscript_float32(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[VECEXT:%.*]] = extractelement <vscale x 4 x float> [[A:%.*]], i64 [[B:%.*]]
// CHECK-NEXT: ret float [[VECEXT]]
//
float subscript_float32(svfloat32_t a, size_t b) {
return a[b];
}
// CHECK-LABEL: @subscript_float64(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[VECEXT:%.*]] = extractelement <vscale x 2 x double> [[A:%.*]], i64 [[B:%.*]]
// CHECK-NEXT: ret double [[VECEXT]]
//
double subscript_float64(svfloat64_t a, size_t b) {
return a[b];
}