diff options
author | seurer <seurer@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-04-28 16:01:52 +0000 |
---|---|---|
committer | seurer <seurer@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-04-28 16:01:52 +0000 |
commit | e40e5340c842f97ef0a3442575325967bebc00da (patch) | |
tree | 815b7ca188aec3bf1ebe9db84f4fcf2eaac04a32 /gcc/testsuite/gcc.target/powerpc/vec-adde.c | |
parent | cf977d50a042b22d767b6316cbcf75d6511398d9 (diff) |
This patch adds support for the signed and unsigned int versions of the
vec_adde altivec builtins from the Power Architecture 64-Bit ELF V2 ABI
OpenPOWER ABI for Linux Supplement (16 July 2015 Version 1.1). There are
many of the builtins that are missing and this is the first of a series
of patches to add them.
There aren't instructions for the int versions of vec_adde so the
output code is built from other built-ins that do have instructions
which in this case is just two vec_adds with a vec_and to ensure the
carry vector is comprised of only the values 0 or 1.
The new test cases are executable tests which verify that the generated
code produces expected values. C macros were used so that the same
test case could be used for both the signed and unsigned versions. An
extra executable test case is also included to ensure that the modified
support for the __int128 versions of vec_adde is not broken. The same
test case could not be used for both int and __int128 because of some
differences in loading and storing the vectors.
Bootstrapped and tested on powerpc64le-unknown-linux-gnu with no
regressions. Is this ok for trunk?
[gcc]
2016-04-28 Bill Seurer <seurer@linux.vnet.ibm.com>
* config/rs6000/rs6000-builtin.def (vec_adde): Change vec_adde to a
special case builtin.
* config/rs6000/rs6000-c.c (altivec_overloaded_builtins): Remove
ALTIVEC_BUILTIN_VEC_ADDE.
* config/rs6000/rs6000-c.c (altivec_resolve_overloaded_builtin): Add
support for ALTIVEC_BUILTIN_VEC_ADDE.
* config/rs6000/rs6000.c (altivec_init_builtins): Add definition
for __builtin_vec_adde.
[gcc/testsuite]
2016-04-28 Bill Seurer <seurer@linux.vnet.ibm.com>
* gcc.target/powerpc/vec-adde.c: New test.
* gcc.target/powerpc/vec-adde-int128.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@235577 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.target/powerpc/vec-adde.c')
-rw-r--r-- | gcc/testsuite/gcc.target/powerpc/vec-adde.c | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/powerpc/vec-adde.c b/gcc/testsuite/gcc.target/powerpc/vec-adde.c new file mode 100644 index 00000000000..b7d5b44b7a7 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vec-adde.c @@ -0,0 +1,77 @@ +/* { dg-do run { target { powerpc64-*-* } } } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */ +/* { dg-options "-mcpu=power8 -O3" } */ + +/* Test that the vec_adde builtin works as expected. */ + +#include "altivec.h" + +#define N 4096 + +void abort (); + +#define define_test_functions(STYPE, NAMESUFFIX) \ +\ +STYPE result_##NAMESUFFIX[N]; \ +STYPE addend1_##NAMESUFFIX[N]; \ +STYPE addend2_##NAMESUFFIX[N]; \ +STYPE carry_##NAMESUFFIX[N]; \ +STYPE expected_##NAMESUFFIX[N]; \ +\ +__attribute__((noinline)) void vector_tests_##NAMESUFFIX () \ +{ \ + int i; \ + vector STYPE v1, v2, v3, tmp; \ + for (i = 0; i < N; i+=16/sizeof(STYPE)) { \ + /* result=addend1+addend2+(carry & 0x1) */ \ + v1 = vec_vsx_ld (0, &addend1_##NAMESUFFIX[i]); \ + v2 = vec_vsx_ld (0, &addend2_##NAMESUFFIX[i]); \ + v3 = vec_vsx_ld (0, &carry_##NAMESUFFIX[i]); \ +\ + tmp = vec_adde (v1, v2, v3); \ + vec_vsx_st (tmp, 0, &result_##NAMESUFFIX[i]); \ + } \ +} \ +\ +__attribute__((noinline)) void init_##NAMESUFFIX () \ +{ \ + int i; \ + for (i = 0; i < N; ++i) { \ + result_##NAMESUFFIX[i] = 0; \ + addend1_##NAMESUFFIX[i] = 1; \ + addend2_##NAMESUFFIX[i] = 2; \ + carry_##NAMESUFFIX[i] = (i%12); \ + expected_##NAMESUFFIX[i] = addend1_##NAMESUFFIX[i] + \ + addend2_##NAMESUFFIX[i] + (carry_##NAMESUFFIX[i] & 0x1); \ + } \ +} \ +\ +__attribute__((noinline)) void verify_results_##NAMESUFFIX () \ +{ \ + for (int i = 0; i < N; ++i) { \ + if (result_##NAMESUFFIX[i] != expected_##NAMESUFFIX[i]) \ + abort(); \ + } \ +} + + +#define execute_test_functions(STYPE, NAMESUFFIX) \ +{ \ + init_##NAMESUFFIX (); \ + vector_tests_##NAMESUFFIX (); \ + verify_results_##NAMESUFFIX (); \ +} + + +define_test_functions(signed int, si); +define_test_functions(unsigned int, ui); + +int main () +{ + execute_test_functions(signed int, si); + execute_test_functions(unsigned int, ui); + + return 0; +} + + |