Skip to content

Commit

Permalink
Remove reliance on lax vector conversions from altivec.h and its test.
Browse files Browse the repository at this point in the history
llvm-svn: 371814
  • Loading branch information
zygoloid committed Sep 13, 2019
1 parent 4aaa77e commit aeb279d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 32 deletions.
4 changes: 2 additions & 2 deletions clang/include/clang/Basic/BuiltinsPPC.def
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ BUILTIN(__builtin_altivec_vavguw, "V4UiV4UiV4Ui", "")

BUILTIN(__builtin_altivec_vrfip, "V4fV4f", "")

BUILTIN(__builtin_altivec_vcfsx, "V4fV4iIi", "")
BUILTIN(__builtin_altivec_vcfux, "V4fV4iIi", "")
BUILTIN(__builtin_altivec_vcfsx, "V4fV4SiIi", "")
BUILTIN(__builtin_altivec_vcfux, "V4fV4UiIi", "")
BUILTIN(__builtin_altivec_vctsxs, "V4SiV4fIi", "")
BUILTIN(__builtin_altivec_vctuxs, "V4UiV4fIi", "")

Expand Down
40 changes: 23 additions & 17 deletions clang/lib/Headers/altivec.h
Original file line number Diff line number Diff line change
Expand Up @@ -2876,9 +2876,10 @@ static __inline__ vector double __ATTRS_o_ai vec_cpsgn(vector double __a,
#ifdef __VSX__
#define vec_ctf(__a, __b) \
_Generic((__a), vector int \
: (vector float)__builtin_altivec_vcfsx((__a), (__b)), \
: (vector float)__builtin_altivec_vcfsx((vector int)(__a), (__b)), \
vector unsigned int \
: (vector float)__builtin_altivec_vcfux((vector int)(__a), (__b)), \
: (vector float)__builtin_altivec_vcfux((vector unsigned int)(__a), \
(__b)), \
vector unsigned long long \
: (__builtin_convertvector((vector unsigned long long)(__a), \
vector double) * \
Expand All @@ -2892,9 +2893,10 @@ static __inline__ vector double __ATTRS_o_ai vec_cpsgn(vector double __a,
#else
#define vec_ctf(__a, __b) \
_Generic((__a), vector int \
: (vector float)__builtin_altivec_vcfsx((__a), (__b)), \
: (vector float)__builtin_altivec_vcfsx((vector int)(__a), (__b)), \
vector unsigned int \
: (vector float)__builtin_altivec_vcfux((vector int)(__a), (__b)))
: (vector float)__builtin_altivec_vcfux((vector unsigned int)(__a), \
(__b)))
#endif

/* vec_vcfsx */
Expand Down Expand Up @@ -16423,27 +16425,27 @@ vec_xl(signed long long __offset, unsigned __int128 *__ptr) {
#ifdef __LITTLE_ENDIAN__
static __inline__ vector signed char __ATTRS_o_ai
vec_xl_be(signed long long __offset, signed char *__ptr) {
vector signed char __vec = __builtin_vsx_lxvd2x_be(__offset, __ptr);
vector signed char __vec = (vector signed char)__builtin_vsx_lxvd2x_be(__offset, __ptr);
return __builtin_shufflevector(__vec, __vec, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14,
13, 12, 11, 10, 9, 8);
}

static __inline__ vector unsigned char __ATTRS_o_ai
vec_xl_be(signed long long __offset, unsigned char *__ptr) {
vector unsigned char __vec = __builtin_vsx_lxvd2x_be(__offset, __ptr);
vector unsigned char __vec = (vector unsigned char)__builtin_vsx_lxvd2x_be(__offset, __ptr);
return __builtin_shufflevector(__vec, __vec, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14,
13, 12, 11, 10, 9, 8);
}

static __inline__ vector signed short __ATTRS_o_ai
vec_xl_be(signed long long __offset, signed short *__ptr) {
vector signed short __vec = __builtin_vsx_lxvd2x_be(__offset, __ptr);
vector signed short __vec = (vector signed short)__builtin_vsx_lxvd2x_be(__offset, __ptr);
return __builtin_shufflevector(__vec, __vec, 3, 2, 1, 0, 7, 6, 5, 4);
}

static __inline__ vector unsigned short __ATTRS_o_ai
vec_xl_be(signed long long __offset, unsigned short *__ptr) {
vector unsigned short __vec = __builtin_vsx_lxvd2x_be(__offset, __ptr);
vector unsigned short __vec = (vector unsigned short)__builtin_vsx_lxvd2x_be(__offset, __ptr);
return __builtin_shufflevector(__vec, __vec, 3, 2, 1, 0, 7, 6, 5, 4);
}

Expand Down Expand Up @@ -16581,7 +16583,8 @@ static __inline__ void __ATTRS_o_ai vec_xst_be(vector signed char __vec,
vector signed char __tmp =
__builtin_shufflevector(__vec, __vec, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14,
13, 12, 11, 10, 9, 8);
__builtin_vsx_stxvd2x_be(__tmp, __offset, __ptr);
typedef __attribute__((vector_size(sizeof(__tmp)))) double __vector_double;
__builtin_vsx_stxvd2x_be((__vector_double)__tmp, __offset, __ptr);
}

static __inline__ void __ATTRS_o_ai vec_xst_be(vector unsigned char __vec,
Expand All @@ -16590,23 +16593,26 @@ static __inline__ void __ATTRS_o_ai vec_xst_be(vector unsigned char __vec,
vector unsigned char __tmp =
__builtin_shufflevector(__vec, __vec, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14,
13, 12, 11, 10, 9, 8);
__builtin_vsx_stxvd2x_be(__tmp, __offset, __ptr);
typedef __attribute__((vector_size(sizeof(__tmp)))) double __vector_double;
__builtin_vsx_stxvd2x_be((__vector_double)__tmp, __offset, __ptr);
}

static __inline__ void __ATTRS_o_ai vec_xst_be(vector signed short __vec,
signed long long __offset,
signed short *__ptr) {
vector signed short __tmp =
__builtin_shufflevector(__vec, __vec, 3, 2, 1, 0, 7, 6, 5, 4);
__builtin_vsx_stxvd2x_be(__tmp, __offset, __ptr);
typedef __attribute__((vector_size(sizeof(__tmp)))) double __vector_double;
__builtin_vsx_stxvd2x_be((__vector_double)__tmp, __offset, __ptr);
}

static __inline__ void __ATTRS_o_ai vec_xst_be(vector unsigned short __vec,
signed long long __offset,
unsigned short *__ptr) {
vector unsigned short __tmp =
__builtin_shufflevector(__vec, __vec, 3, 2, 1, 0, 7, 6, 5, 4);
__builtin_vsx_stxvd2x_be(__tmp, __offset, __ptr);
typedef __attribute__((vector_size(sizeof(__tmp)))) double __vector_double;
__builtin_vsx_stxvd2x_be((__vector_double)__tmp, __offset, __ptr);
}

static __inline__ void __ATTRS_o_ai vec_xst_be(vector signed int __vec,
Expand All @@ -16618,32 +16624,32 @@ static __inline__ void __ATTRS_o_ai vec_xst_be(vector signed int __vec,
static __inline__ void __ATTRS_o_ai vec_xst_be(vector unsigned int __vec,
signed long long __offset,
unsigned int *__ptr) {
__builtin_vsx_stxvw4x_be(__vec, __offset, __ptr);
__builtin_vsx_stxvw4x_be((vector int)__vec, __offset, __ptr);
}

static __inline__ void __ATTRS_o_ai vec_xst_be(vector float __vec,
signed long long __offset,
float *__ptr) {
__builtin_vsx_stxvw4x_be(__vec, __offset, __ptr);
__builtin_vsx_stxvw4x_be((vector int)__vec, __offset, __ptr);
}

#ifdef __VSX__
static __inline__ void __ATTRS_o_ai vec_xst_be(vector signed long long __vec,
signed long long __offset,
signed long long *__ptr) {
__builtin_vsx_stxvd2x_be(__vec, __offset, __ptr);
__builtin_vsx_stxvd2x_be((vector double)__vec, __offset, __ptr);
}

static __inline__ void __ATTRS_o_ai vec_xst_be(vector unsigned long long __vec,
signed long long __offset,
unsigned long long *__ptr) {
__builtin_vsx_stxvd2x_be(__vec, __offset, __ptr);
__builtin_vsx_stxvd2x_be((vector double)__vec, __offset, __ptr);
}

static __inline__ void __ATTRS_o_ai vec_xst_be(vector double __vec,
signed long long __offset,
double *__ptr) {
__builtin_vsx_stxvd2x_be(__vec, __offset, __ptr);
__builtin_vsx_stxvd2x_be((vector double)__vec, __offset, __ptr);
}
#endif

Expand Down
26 changes: 13 additions & 13 deletions clang/test/CodeGen/builtins-ppc-altivec.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// REQUIRES: powerpc-registered-target
// RUN: %clang_cc1 -target-feature +altivec -triple powerpc-unknown-unknown -emit-llvm %s \
// RUN: -o - | FileCheck %s
// RUN: -flax-vector-conversions=none -o - | FileCheck %s
// RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown -emit-llvm %s \
// RUN: -o - | FileCheck %s
// RUN: -flax-vector-conversions=none -o - | FileCheck %s
// RUN: %clang_cc1 -target-feature +altivec -triple powerpc64le-unknown-unknown -emit-llvm %s \
// RUN: -o - | FileCheck %s -check-prefix=CHECK-LE
// RUN: -flax-vector-conversions=none -o - | FileCheck %s -check-prefix=CHECK-LE
// RUN: not %clang_cc1 -triple powerpc64le-unknown-unknown -emit-llvm %s \
// RUN: -ferror-limit 0 -DNO_ALTIVEC -o - 2>&1 \
// RUN: | FileCheck %s -check-prefix=CHECK-NOALTIVEC
Expand Down Expand Up @@ -2419,7 +2419,7 @@ void test6() {
// CHECK-LE: or <16 x i8>
// CHECK-LE: xor <16 x i8>

res_vuc = vec_nor(vbc, vbc);
res_vbc = vec_nor(vbc, vbc);
// CHECK: or <16 x i8>
// CHECK: xor <16 x i8>
// CHECK-LE: or <16 x i8>
Expand All @@ -2437,7 +2437,7 @@ void test6() {
// CHECK-LE: or <8 x i16>
// CHECK-LE: xor <8 x i16>

res_vus = vec_nor(vbs, vbs);
res_vbs = vec_nor(vbs, vbs);
// CHECK: or <8 x i16>
// CHECK: xor <8 x i16>
// CHECK-LE: or <8 x i16>
Expand All @@ -2455,7 +2455,7 @@ void test6() {
// CHECK-LE: or <4 x i32>
// CHECK-LE: xor <4 x i32>

res_vui = vec_nor(vbi, vbi);
res_vbi = vec_nor(vbi, vbi);
// CHECK: or <4 x i32>
// CHECK: xor <4 x i32>
// CHECK-LE: or <4 x i32>
Expand All @@ -2479,7 +2479,7 @@ void test6() {
// CHECK-LE: or <16 x i8>
// CHECK-LE: xor <16 x i8>

res_vuc = vec_vnor(vbc, vbc);
res_vbc = vec_vnor(vbc, vbc);
// CHECK: or <16 x i8>
// CHECK: xor <16 x i8>
// CHECK-LE: or <16 x i8>
Expand All @@ -2497,7 +2497,7 @@ void test6() {
// CHECK-LE: or <8 x i16>
// CHECK-LE: xor <8 x i16>

res_vus = vec_vnor(vbs, vbs);
res_vbs = vec_vnor(vbs, vbs);
// CHECK: or <8 x i16>
// CHECK: xor <8 x i16>
// CHECK-LE: or <8 x i16>
Expand All @@ -2515,7 +2515,7 @@ void test6() {
// CHECK-LE: or <4 x i32>
// CHECK-LE: xor <4 x i32>

res_vui = vec_vnor(vbi, vbi);
res_vbi = vec_vnor(vbi, vbi);
// CHECK: or <4 x i32>
// CHECK: xor <4 x i32>
// CHECK-LE: or <4 x i32>
Expand Down Expand Up @@ -5385,11 +5385,11 @@ void test6() {
// CHECK: sub <8 x i16>
// CHECK-LE: sub <8 x i16>

res_vs = vec_vsubuhm(vbs, vus);
res_vs = vec_vsubuhm(vbs, vs);
// CHECK: sub <8 x i16>
// CHECK-LE: sub <8 x i16>

res_vs = vec_vsubuhm(vus, vbs);
res_vs = vec_vsubuhm(vs, vbs);
// CHECK: sub <8 x i16>
// CHECK-LE: sub <8 x i16>

Expand Down Expand Up @@ -9251,11 +9251,11 @@ void test8() {
// CHECK: shufflevector <8 x i16> %{{[0-9]+}}, <8 x i16> %{{[0-9]+}}, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
// CHECK-LE: shufflevector <8 x i16> %{{[0-9]+}}, <8 x i16> %{{[0-9]+}}, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>

res_vbs = vec_reve(vs);
res_vs = vec_reve(vs);
// CHECK: shufflevector <8 x i16> %{{[0-9]+}}, <8 x i16> %{{[0-9]+}}, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
// CHECK-LE: shufflevector <8 x i16> %{{[0-9]+}}, <8 x i16> %{{[0-9]+}}, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>

res_vbs = vec_reve(vus);
res_vus = vec_reve(vus);
// CHECK: shufflevector <8 x i16> %{{[0-9]+}}, <8 x i16> %{{[0-9]+}}, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
// CHECK-LE: shufflevector <8 x i16> %{{[0-9]+}}, <8 x i16> %{{[0-9]+}}, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>

Expand Down

0 comments on commit aeb279d

Please sign in to comment.