Files
clang-p2996/clang/test/CodeGen/SystemZ/builtins-systemz-zvector2-error.c
Ulrich Weigand a65ccc1b9f [SystemZ] Support i128 as legal type in VRs (#74625)
On processors supporting vector registers and SIMD instructions, enable
i128 as legal type in VRs. This allows many operations to be implemented
via native instructions directly in VRs (including add, subtract,
logical operations and shifts). For a few other operations (e.g.
multiply and divide, as well as atomic operations), we need to move the
i128 value back to a GPR pair to use the corresponding instruction
there. Overall, this is still beneficial.

The patch includes the following LLVM changes:
- Enable i128 as legal type
- Set up legal operations (in SystemZInstrVector.td)
- Custom expansion for i128 add/subtract with carry
- Custom expansion for i128 comparisons and selects
- Support for moving i128 to/from GPR pairs when required
- Handle 128-bit integer constant values everywhere
- Use i128 as intrinsic operand type where appropriate
- Updated and new test cases

In addition, clang builtins are updated to reflect the intrinsic operand
type changes (which also improves compatibility with GCC).
2023-12-15 12:55:15 +01:00

157 lines
11 KiB
C

// REQUIRES: systemz-registered-target
// RUN: %clang_cc1 -target-cpu z14 -triple s390x-linux-gnu \
// RUN: -fzvector -flax-vector-conversions=none \
// RUN: -Wall -Wno-unused -Werror -fsyntax-only -verify %s
#include <vecintrin.h>
volatile vector signed char vsc;
volatile vector signed short vss;
volatile vector signed int vsi;
volatile vector signed long long vsl;
volatile vector unsigned char vuc;
volatile vector unsigned short vus;
volatile vector unsigned int vui;
volatile vector unsigned long long vul;
volatile vector bool char vbc;
volatile vector bool short vbs;
volatile vector bool int vbi;
volatile vector bool long long vbl;
volatile vector float vf;
volatile vector double vd;
volatile signed char sc;
volatile signed short ss;
volatile signed int si;
volatile signed long long sl;
volatile unsigned char uc;
volatile unsigned short us;
volatile unsigned int ui;
volatile unsigned long long ul;
volatile float f;
volatile double d;
const void * volatile cptr;
const signed char * volatile cptrsc;
const signed short * volatile cptrss;
const signed int * volatile cptrsi;
const signed long long * volatile cptrsl;
const unsigned char * volatile cptruc;
const unsigned short * volatile cptrus;
const unsigned int * volatile cptrui;
const unsigned long long * volatile cptrul;
const float * volatile cptrf;
const double * volatile cptrd;
void * volatile ptr;
signed char * volatile ptrsc;
signed short * volatile ptrss;
signed int * volatile ptrsi;
signed long long * volatile ptrsl;
unsigned char * volatile ptruc;
unsigned short * volatile ptrus;
unsigned int * volatile ptrui;
unsigned long long * volatile ptrul;
float * volatile ptrf;
double * volatile ptrd;
volatile unsigned int len;
volatile int idx;
int cc;
void test_core(void) {
vf = vec_gather_element(vf, vui, cptrf, idx); // expected-error {{no matching function}}
// expected-note@vecintrin.h:* 7 {{candidate function not viable}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 3}}
vf = vec_gather_element(vf, vui, cptrf, -1); // expected-error {{no matching function}}
// expected-note@vecintrin.h:* 7 {{candidate function not viable}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 3}}
vf = vec_gather_element(vf, vui, cptrf, 4); // expected-error {{no matching function}}
// expected-note@vecintrin.h:* 7 {{candidate function not viable}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 3}}
vd = vec_gather_element(vd, vul, cptrd, idx); // expected-error {{no matching function}}
// expected-note@vecintrin.h:* 7 {{candidate function not viable}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 1}}
vd = vec_gather_element(vd, vul, cptrd, -1); // expected-error {{no matching function}}
// expected-note@vecintrin.h:* 7 {{candidate function not viable}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 1}}
vd = vec_gather_element(vd, vul, cptrd, 2); // expected-error {{no matching function}}
// expected-note@vecintrin.h:* 7 {{candidate function not viable}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 1}}
vec_scatter_element(vf, vui, ptrf, idx); // expected-error {{no matching function}}
// expected-note@vecintrin.h:* 7 {{candidate function not viable}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 3}}
vec_scatter_element(vf, vui, ptrf, -1); // expected-error {{no matching function}}
// expected-note@vecintrin.h:* 7 {{candidate function not viable}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 3}}
vec_scatter_element(vf, vui, ptrf, 4); // expected-error {{no matching function}}
// expected-note@vecintrin.h:* 7 {{candidate function not viable}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 3}}
vec_scatter_element(vd, vul, ptrd, idx); // expected-error {{no matching function}}
// expected-note@vecintrin.h:* 7 {{candidate function not viable}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 1}}
vec_scatter_element(vd, vul, ptrd, -1); // expected-error {{no matching function}}
// expected-note@vecintrin.h:* 7 {{candidate function not viable}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 1}}
vec_scatter_element(vd, vul, ptrd, 2); // expected-error {{no matching function}}
// expected-note@vecintrin.h:* 7 {{candidate function not viable}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 1}}
vf = vec_splat(vf, idx); // expected-error {{no matching function}}
// expected-note@vecintrin.h:* 13 {{candidate function not viable}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 3}}
vf = vec_splat(vf, -1); // expected-error {{no matching function}}
// expected-note@vecintrin.h:* 13 {{candidate function not viable}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 3}}
vf = vec_splat(vf, 4); // expected-error {{no matching function}}
// expected-note@vecintrin.h:* 13 {{candidate function not viable}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 3}}
vd = vec_splat(vd, idx); // expected-error {{no matching function}}
// expected-note@vecintrin.h:* 13 {{candidate function not viable}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 1}}
vd = vec_splat(vd, -1); // expected-error {{no matching function}}
// expected-note@vecintrin.h:* 13 {{candidate function not viable}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 1}}
vd = vec_splat(vd, 2); // expected-error {{no matching function}}
// expected-note@vecintrin.h:* 13 {{candidate function not viable}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 1}}
}
void test_integer(void) {
vf = vec_sld(vf, vf, idx); // expected-error {{no matching function}} expected-error {{argument to '__builtin_s390_vsldb' must be a constant integer}}
// expected-note@vecintrin.h:* 13 {{candidate function not viable}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 15}}
vd = vec_sld(vd, vd, idx); // expected-error {{no matching function}} expected-error {{argument to '__builtin_s390_vsldb' must be a constant integer}}
// expected-note@vecintrin.h:* 13 {{candidate function not viable}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 15}}
vuc = vec_msum_u128(vul, vul, vuc, idx); // expected-error {{no matching function}} expected-error {{argument to '__builtin_s390_vmslg' must be a constant integer}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 15}}
vuc = vec_msum_u128(vul, vul, vuc, -1); // expected-error {{no matching function}} expected-error {{argument value -1 is outside the valid range [0, 15]}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 15}}
vuc = vec_msum_u128(vul, vul, vuc, 16); // expected-error {{no matching function}} expected-error {{argument value 16 is outside the valid range [0, 15]}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 15}}
}
void test_float(void) {
vbi = vec_fp_test_data_class(vf, idx, &cc); // expected-error {{no matching function}} expected-error {{argument to '__builtin_s390_vftcisb' must be a constant integer}} expected-error {{argument to '__builtin_s390_vftcidb' must be a constant integer}}
// expected-note@vecintrin.h:* 1 {{candidate function not viable}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 4095}}
vbi = vec_fp_test_data_class(vf, -1, &cc); // expected-error {{no matching function}} expected-error 2{{argument value -1 is outside the valid range [0, 4095]}}
// expected-note@vecintrin.h:* 1 {{candidate function not viable}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 4095}}
vbi = vec_fp_test_data_class(vf, 4096, &cc); // expected-error {{no matching function}} expected-error 2{{argument value 4096 is outside the valid range [0, 4095]}}
// expected-note@vecintrin.h:* 1 {{candidate function not viable}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 4095}}
vbl = vec_fp_test_data_class(vd, idx, &cc); // expected-error {{no matching function}} expected-error {{argument to '__builtin_s390_vftcisb' must be a constant integer}} expected-error {{argument to '__builtin_s390_vftcidb' must be a constant integer}}
// expected-note@vecintrin.h:* 1 {{candidate function not viable}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 4095}}
vbl = vec_fp_test_data_class(vd, -1, &cc); // expected-error {{no matching function}} expected-error 2{{argument value -1 is outside the valid range [0, 4095]}}
// expected-note@vecintrin.h:* 1 {{candidate function not viable}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 4095}}
vbl = vec_fp_test_data_class(vd, 4096, &cc); // expected-error {{no matching function}} expected-error 2{{argument value 4096 is outside the valid range [0, 4095]}}
// expected-note@vecintrin.h:* 1 {{candidate function not viable}}
// expected-note@vecintrin.h:* 1 {{must be a constant integer from 0 to 4095}}
}