diff options
author | Richard Sandiford <richard.sandiford@linaro.org> | 2018-05-25 08:53:15 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2018-05-25 08:53:15 +0000 |
commit | 6c4fd4a9fec0af65249a11e44341b5f3f5b209b3 (patch) | |
tree | 576629be877f48bb03c0853d1d4042f0e055b62a /gcc/testsuite/gcc.target | |
parent | c38f73190ba3669a9cd8b57626b9d0e7087fd55c (diff) | |
download | gcc-6c4fd4a9fec0af65249a11e44341b5f3f5b209b3.zip gcc-6c4fd4a9fec0af65249a11e44341b5f3f5b209b3.tar.gz gcc-6c4fd4a9fec0af65249a11e44341b5f3f5b209b3.tar.bz2 |
Add IFN_COND_{MUL,DIV,MOD,RDIV}
This patch adds support for conditional multiplication and division.
It's mostly mechanical, but a few notes:
* The *_optab name and the .md names are the same as the unconditional
forms, just with "cond_" added to the front. This means we still
have the awkward difference between sdiv and div, etc.
* It was easier to retain the difference between integer and FP
division in the function names, given that they map to different
tree codes (TRUNC_DIV_EXPR and RDIV_EXPR).
* SVE has no direct support for IFN_COND_MOD, but it seemed more
consistent to add it anyway.
* Adding IFN_COND_MUL enables an extra fully-masked reduction
in gcc.dg/vect/pr53773.c.
* In practice we don't actually use the integer division forms without
if-conversion support (added by a later patch).
2018-05-25 Richard Sandiford <richard.sandiford@linaro.org>
gcc/
* doc/sourcebuild.texi (vect_double_cond_arith): Include
multiplication and division.
* doc/md.texi (cond_mul@var{m}, cond_div@var{m}, cond_mod@var{m})
(cond_udiv@var{m}, cond_umod@var{m}): Document.
* optabs.def (cond_smul_optab, cond_sdiv_optab, cond_smod_optab)
(cond_udiv_optab, cond_umod_optab): New optabs.
* internal-fn.def (IFN_COND_MUL, IFN_COND_DIV, IFN_COND_MOD)
(IFN_COND_RDIV): New internal functions.
* internal-fn.c (get_conditional_internal_fn): Handle TRUNC_DIV_EXPR,
TRUNC_MOD_EXPR and RDIV_EXPR.
* match.pd (UNCOND_BINARY, COND_BINARY): Handle them.
* config/aarch64/iterators.md (UNSPEC_COND_MUL, UNSPEC_COND_DIV):
New unspecs.
(SVE_INT_BINARY): Include mult.
(SVE_COND_FP_BINARY): Include UNSPEC_MUL and UNSPEC_DIV.
(optab, sve_int_op): Handle mult.
(optab, sve_fp_op, commutative): Handle UNSPEC_COND_MUL and
UNSPEC_COND_DIV.
* config/aarch64/aarch64-sve.md (cond_<optab><mode>): New pattern
for SVE_INT_BINARY_SD.
gcc/testsuite/
* lib/target-supports.exp
(check_effective_target_vect_double_cond_arith): Include
multiplication and division.
* gcc.dg/vect/pr53773.c: Do not expect a scalar tail when using
fully-masked loops with a fixed vector length.
* gcc.dg/vect/vect-cond-arith-1.c: Add multiplication and division
tests.
* gcc.target/aarch64/sve/vcond_8.c: Likewise.
* gcc.target/aarch64/sve/vcond_9.c: Likewise.
* gcc.target/aarch64/sve/vcond_12.c: Add multiplication tests.
From-SVN: r260713
Diffstat (limited to 'gcc/testsuite/gcc.target')
-rw-r--r-- | gcc/testsuite/gcc.target/aarch64/sve/vcond_12.c | 22 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/aarch64/sve/vcond_8.c | 18 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/aarch64/sve/vcond_9.c | 18 |
3 files changed, 54 insertions, 4 deletions
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/vcond_12.c b/gcc/testsuite/gcc.target/aarch64/sve/vcond_12.c index 95b371a..de650bf 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/vcond_12.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/vcond_12.c @@ -5,6 +5,8 @@ #define add(A, B) ((A) + (B)) #define sub(A, B) ((A) - (B)) +#define mul(A, B) ((A) * (B)) +#define div(A, B) ((A) / (B)) #define max(A, B) ((A) > (B) ? (A) : (B)) #define min(A, B) ((A) < (B) ? (A) : (B)) #define and(A, B) ((A) & (B)) @@ -29,6 +31,7 @@ #define FOR_EACH_INT_TYPE(T, TYPE) \ T (TYPE, TYPE, add) \ T (TYPE, TYPE, sub) \ + T (TYPE, TYPE, mul) \ T (TYPE, TYPE, max) \ T (TYPE, TYPE, min) \ T (TYPE, TYPE, and) \ @@ -38,6 +41,8 @@ #define FOR_EACH_FP_TYPE(T, TYPE, CMPTYPE, SUFFIX) \ T (TYPE, CMPTYPE, add) \ T (TYPE, CMPTYPE, sub) \ + T (TYPE, CMPTYPE, mul) \ + /* No div because that gets converted into a mul anyway. */ \ T (TYPE, CMPTYPE, __builtin_fmax##SUFFIX) \ T (TYPE, CMPTYPE, __builtin_fmin##SUFFIX) @@ -58,10 +63,10 @@ FOR_EACH_LOOP (DEF_LOOP) /* { dg-final { scan-assembler-not {\tmov\tz[0-9]+\.., z[0-9]+} } } */ -/* { dg-final { scan-assembler-times {\tsel\tz[0-9]+\.b,} 14 } } */ -/* { dg-final { scan-assembler-times {\tsel\tz[0-9]+\.h,} 18 } } */ -/* { dg-final { scan-assembler-times {\tsel\tz[0-9]+\.s,} 18 } } */ -/* { dg-final { scan-assembler-times {\tsel\tz[0-9]+\.d,} 18 } } */ +/* { dg-final { scan-assembler-times {\tsel\tz[0-9]+\.b,} 16 } } */ +/* { dg-final { scan-assembler-times {\tsel\tz[0-9]+\.h,} 21 } } */ +/* { dg-final { scan-assembler-times {\tsel\tz[0-9]+\.s,} 21 } } */ +/* { dg-final { scan-assembler-times {\tsel\tz[0-9]+\.d,} 21 } } */ /* { dg-final { scan-assembler-times {\tadd\tz[0-9]+\.b, p[0-7]/m,} 2 } } */ /* { dg-final { scan-assembler-times {\tadd\tz[0-9]+\.h, p[0-7]/m,} 2 } } */ @@ -73,6 +78,11 @@ FOR_EACH_LOOP (DEF_LOOP) /* { dg-final { scan-assembler-times {\tsub\tz[0-9]+\.s, p[0-7]/m,} 2 } } */ /* { dg-final { scan-assembler-times {\tsub\tz[0-9]+\.d, p[0-7]/m,} 2 } } */ +/* { dg-final { scan-assembler-times {\tmul\tz[0-9]+\.b, p[0-7]/m,} 2 } } */ +/* { dg-final { scan-assembler-times {\tmul\tz[0-9]+\.h, p[0-7]/m,} 2 } } */ +/* { dg-final { scan-assembler-times {\tmul\tz[0-9]+\.s, p[0-7]/m,} 2 } } */ +/* { dg-final { scan-assembler-times {\tmul\tz[0-9]+\.d, p[0-7]/m,} 2 } } */ + /* { dg-final { scan-assembler-times {\tsmax\tz[0-9]+\.b, p[0-7]/m,} 1 } } */ /* { dg-final { scan-assembler-times {\tsmax\tz[0-9]+\.h, p[0-7]/m,} 1 } } */ /* { dg-final { scan-assembler-times {\tsmax\tz[0-9]+\.s, p[0-7]/m,} 1 } } */ @@ -116,6 +126,10 @@ FOR_EACH_LOOP (DEF_LOOP) /* { dg-final { scan-assembler-times {\tfsub\tz[0-9]+\.s, p[0-7]/m,} 1 } } */ /* { dg-final { scan-assembler-times {\tfsub\tz[0-9]+\.d, p[0-7]/m,} 1 } } */ +/* { dg-final { scan-assembler-times {\tfmul\tz[0-9]+\.h, p[0-7]/m,} 1 } } */ +/* { dg-final { scan-assembler-times {\tfmul\tz[0-9]+\.s, p[0-7]/m,} 1 } } */ +/* { dg-final { scan-assembler-times {\tfmul\tz[0-9]+\.d, p[0-7]/m,} 1 } } */ + /* { dg-final { scan-assembler-times {\tfmaxnm\tz[0-9]+\.h, p[0-7]/m,} 1 } } */ /* { dg-final { scan-assembler-times {\tfmaxnm\tz[0-9]+\.s, p[0-7]/m,} 1 } } */ /* { dg-final { scan-assembler-times {\tfmaxnm\tz[0-9]+\.d, p[0-7]/m,} 1 } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/vcond_8.c b/gcc/testsuite/gcc.target/aarch64/sve/vcond_8.c index c32ab59..d49dee7 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/vcond_8.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/vcond_8.c @@ -5,6 +5,8 @@ #define add(A, B) ((A) + (B)) #define sub(A, B) ((A) - (B)) +#define mul(A, B) ((A) * (B)) +#define div(A, B) ((A) / (B)) #define max(A, B) ((A) > (B) ? (A) : (B)) #define min(A, B) ((A) < (B) ? (A) : (B)) #define and(A, B) ((A) & (B)) @@ -27,6 +29,7 @@ #define FOR_EACH_INT_TYPE(T, TYPE) \ T (TYPE, TYPE, add) \ T (TYPE, TYPE, sub) \ + T (TYPE, TYPE, mul) \ T (TYPE, TYPE, max) \ T (TYPE, TYPE, min) \ T (TYPE, TYPE, and) \ @@ -36,6 +39,8 @@ #define FOR_EACH_FP_TYPE(T, TYPE, CMPTYPE, SUFFIX) \ T (TYPE, CMPTYPE, add) \ T (TYPE, CMPTYPE, sub) \ + T (TYPE, CMPTYPE, mul) \ + T (TYPE, CMPTYPE, div) \ T (TYPE, CMPTYPE, __builtin_fmax##SUFFIX) \ T (TYPE, CMPTYPE, __builtin_fmin##SUFFIX) @@ -67,6 +72,11 @@ FOR_EACH_LOOP (DEF_LOOP) /* { dg-final { scan-assembler-times {\tsub\tz[0-9]+\.s, p[0-7]/m,} 2 } } */ /* { dg-final { scan-assembler-times {\tsub\tz[0-9]+\.d, p[0-7]/m,} 2 } } */ +/* { dg-final { scan-assembler-times {\tmul\tz[0-9]+\.b, p[0-7]/m,} 2 } } */ +/* { dg-final { scan-assembler-times {\tmul\tz[0-9]+\.h, p[0-7]/m,} 2 } } */ +/* { dg-final { scan-assembler-times {\tmul\tz[0-9]+\.s, p[0-7]/m,} 2 } } */ +/* { dg-final { scan-assembler-times {\tmul\tz[0-9]+\.d, p[0-7]/m,} 2 } } */ + /* { dg-final { scan-assembler-times {\tsmax\tz[0-9]+\.b, p[0-7]/m,} 1 } } */ /* { dg-final { scan-assembler-times {\tsmax\tz[0-9]+\.h, p[0-7]/m,} 1 } } */ /* { dg-final { scan-assembler-times {\tsmax\tz[0-9]+\.s, p[0-7]/m,} 1 } } */ @@ -110,6 +120,14 @@ FOR_EACH_LOOP (DEF_LOOP) /* { dg-final { scan-assembler-times {\tfsub\tz[0-9]+\.s, p[0-7]/m,} 1 } } */ /* { dg-final { scan-assembler-times {\tfsub\tz[0-9]+\.d, p[0-7]/m,} 1 } } */ +/* { dg-final { scan-assembler-times {\tfmul\tz[0-9]+\.h, p[0-7]/m,} 1 } } */ +/* { dg-final { scan-assembler-times {\tfmul\tz[0-9]+\.s, p[0-7]/m,} 1 } } */ +/* { dg-final { scan-assembler-times {\tfmul\tz[0-9]+\.d, p[0-7]/m,} 1 } } */ + +/* { dg-final { scan-assembler-times {\tfdiv\tz[0-9]+\.h, p[0-7]/m,} 1 } } */ +/* { dg-final { scan-assembler-times {\tfdiv\tz[0-9]+\.s, p[0-7]/m,} 1 } } */ +/* { dg-final { scan-assembler-times {\tfdiv\tz[0-9]+\.d, p[0-7]/m,} 1 } } */ + /* { dg-final { scan-assembler-times {\tfmaxnm\tz[0-9]+\.h, p[0-7]/m,} 1 } } */ /* { dg-final { scan-assembler-times {\tfmaxnm\tz[0-9]+\.s, p[0-7]/m,} 1 } } */ /* { dg-final { scan-assembler-times {\tfmaxnm\tz[0-9]+\.d, p[0-7]/m,} 1 } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/vcond_9.c b/gcc/testsuite/gcc.target/aarch64/sve/vcond_9.c index 618e187..806af7f 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/vcond_9.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/vcond_9.c @@ -5,6 +5,8 @@ #define add(A, B) ((A) + (B)) #define sub(A, B) ((A) - (B)) +#define mul(A, B) ((A) * (B)) +#define div(A, B) ((A) / (B)) #define max(A, B) ((A) > (B) ? (A) : (B)) #define min(A, B) ((A) < (B) ? (A) : (B)) #define and(A, B) ((A) & (B)) @@ -27,6 +29,7 @@ #define FOR_EACH_INT_TYPE(T, TYPE) \ T (TYPE, TYPE, add) \ T (TYPE, TYPE, sub) \ + T (TYPE, TYPE, mul) \ T (TYPE, TYPE, max) \ T (TYPE, TYPE, min) \ T (TYPE, TYPE, and) \ @@ -36,6 +39,8 @@ #define FOR_EACH_FP_TYPE(T, TYPE, CMPTYPE, SUFFIX) \ T (TYPE, CMPTYPE, add) \ T (TYPE, CMPTYPE, sub) \ + T (TYPE, CMPTYPE, mul) \ + T (TYPE, CMPTYPE, div) \ T (TYPE, CMPTYPE, __builtin_fmax##SUFFIX) \ T (TYPE, CMPTYPE, __builtin_fmin##SUFFIX) @@ -67,6 +72,11 @@ FOR_EACH_LOOP (DEF_LOOP) /* { dg-final { scan-assembler-times {\tsubr\tz[0-9]+\.s, p[0-7]/m,} 2 } } */ /* { dg-final { scan-assembler-times {\tsubr\tz[0-9]+\.d, p[0-7]/m,} 2 } } */ +/* { dg-final { scan-assembler-times {\tmul\tz[0-9]+\.b, p[0-7]/m,} 2 } } */ +/* { dg-final { scan-assembler-times {\tmul\tz[0-9]+\.h, p[0-7]/m,} 2 } } */ +/* { dg-final { scan-assembler-times {\tmul\tz[0-9]+\.s, p[0-7]/m,} 2 } } */ +/* { dg-final { scan-assembler-times {\tmul\tz[0-9]+\.d, p[0-7]/m,} 2 } } */ + /* { dg-final { scan-assembler-times {\tsmax\tz[0-9]+\.b, p[0-7]/m,} 1 } } */ /* { dg-final { scan-assembler-times {\tsmax\tz[0-9]+\.h, p[0-7]/m,} 1 } } */ /* { dg-final { scan-assembler-times {\tsmax\tz[0-9]+\.s, p[0-7]/m,} 1 } } */ @@ -110,6 +120,14 @@ FOR_EACH_LOOP (DEF_LOOP) /* { dg-final { scan-assembler-times {\tfsubr\tz[0-9]+\.s, p[0-7]/m,} 1 } } */ /* { dg-final { scan-assembler-times {\tfsubr\tz[0-9]+\.d, p[0-7]/m,} 1 } } */ +/* { dg-final { scan-assembler-times {\tfmul\tz[0-9]+\.h, p[0-7]/m,} 1 } } */ +/* { dg-final { scan-assembler-times {\tfmul\tz[0-9]+\.s, p[0-7]/m,} 1 } } */ +/* { dg-final { scan-assembler-times {\tfmul\tz[0-9]+\.d, p[0-7]/m,} 1 } } */ + +/* { dg-final { scan-assembler-times {\tfdivr\tz[0-9]+\.h, p[0-7]/m,} 1 } } */ +/* { dg-final { scan-assembler-times {\tfdivr\tz[0-9]+\.s, p[0-7]/m,} 1 } } */ +/* { dg-final { scan-assembler-times {\tfdivr\tz[0-9]+\.d, p[0-7]/m,} 1 } } */ + /* { dg-final { scan-assembler-times {\tfmaxnm\tz[0-9]+\.h, p[0-7]/m,} 1 } } */ /* { dg-final { scan-assembler-times {\tfmaxnm\tz[0-9]+\.s, p[0-7]/m,} 1 } } */ /* { dg-final { scan-assembler-times {\tfmaxnm\tz[0-9]+\.d, p[0-7]/m,} 1 } } */ |