From d0939f42dd84ca03212caf0b6937cf201a16a44f Mon Sep 17 00:00:00 2001 From: Kewen Lin Date: Sun, 30 Aug 2020 19:52:03 -0500 Subject: [PATCH] testsuite: Update some vect cases for partial vectors This patch is to adjust some existing vectorization test cases to work well with the newly introduced partial vector usages. Bootstrapped/regtested on aarch64-linux-gnu and powerpc64le-linux-gnu P9 (with explicit param vect-partial-vector-usage=1 and enablement on check_effective_target_vect_partial_vectors_usage_1 check). gcc/ChangeLog: * doc/sourcebuild.texi (vect_len_load_store, vect_partial_vectors_usage_1, vect_partial_vectors_usage_2, vect_partial_vectors): Document. gcc/testsuite/ChangeLog: * gcc.dg/vect/bb-slp-pr69907.c: Adjust for partial vector usages. * gcc.dg/vect/slp-3.c: Likewise. * gcc.dg/vect/slp-multitypes-11.c: Likewise. * gcc.dg/vect/slp-perm-1.c: Likewise. * gcc.dg/vect/slp-perm-5.c: Likewise. * gcc.dg/vect/slp-perm-6.c: Likewise. * gcc.dg/vect/slp-perm-7.c: Likewise. * gcc.dg/vect/slp-perm-8.c: Likewise. * gcc.dg/vect/slp-perm-9.c: Likewise. * gcc.dg/vect/vect-version-2.c: Likewise. * lib/target-supports.exp (check_vect_partial_vector_usage): New function. (check_effective_target_vect_len_load_store): Likewise. (check_effective_target_vect_partial_vectors_usage_1): Likewise. (check_effective_target_vect_partial_vectors_usage_2): Likewise. (check_effective_target_vect_partial_vectors): Likewise. --- gcc/doc/sourcebuild.texi | 15 +++++ gcc/testsuite/gcc.dg/vect/bb-slp-pr69907.c | 4 +- gcc/testsuite/gcc.dg/vect/slp-3.c | 8 +-- gcc/testsuite/gcc.dg/vect/slp-multitypes-11.c | 4 +- gcc/testsuite/gcc.dg/vect/slp-perm-1.c | 4 +- gcc/testsuite/gcc.dg/vect/slp-perm-5.c | 4 +- gcc/testsuite/gcc.dg/vect/slp-perm-6.c | 4 +- gcc/testsuite/gcc.dg/vect/slp-perm-7.c | 4 +- gcc/testsuite/gcc.dg/vect/slp-perm-8.c | 4 +- gcc/testsuite/gcc.dg/vect/slp-perm-9.c | 4 +- gcc/testsuite/gcc.dg/vect/vect-version-2.c | 6 +- gcc/testsuite/lib/target-supports.exp | 61 +++++++++++++++++++ 12 files changed, 109 insertions(+), 13 deletions(-) diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 967cb135cb4..f7c69362f91 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -1711,6 +1711,21 @@ Target supports AND, IOR and XOR reduction on vectors. @item vect_fold_extract_last Target supports the @code{fold_extract_last} optab. + +@item vect_len_load_store +Target supports the @code{len_load} and @code{len_store} optabs. + +@item vect_partial_vectors_usage_1 +Target supports loop vectorization with partial vectors and +@code{vect-partial-vector-usage} is set to 1. + +@item vect_partial_vectors_usage_2 +Target supports loop vectorization with partial vectors and +@code{vect-partial-vector-usage} is set to 2. + +@item vect_partial_vectors +Target supports loop vectorization with partial vectors and +@code{vect-partial-vector-usage} is nonzero. @end table @subsubsection Thread Local Storage attributes diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr69907.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr69907.c index fe52d18525a..b348526b62f 100644 --- a/gcc/testsuite/gcc.dg/vect/bb-slp-pr69907.c +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr69907.c @@ -1,5 +1,7 @@ /* { dg-do compile } */ -/* { dg-additional-options "-O3" } */ +/* Disable for vectorization using partial vectors since it would have only + one iteration left, consequently BB vectorization won't happen. */ +/* { dg-additional-options "-O3 --param=vect-partial-vector-usage=0" } */ /* { dg-require-effective-target vect_unpack } */ #include "tree-vect.h" diff --git a/gcc/testsuite/gcc.dg/vect/slp-3.c b/gcc/testsuite/gcc.dg/vect/slp-3.c index 5e40499ff96..46ab584419a 100644 --- a/gcc/testsuite/gcc.dg/vect/slp-3.c +++ b/gcc/testsuite/gcc.dg/vect/slp-3.c @@ -141,8 +141,8 @@ int main (void) return 0; } -/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { target { ! vect_fully_masked } } } } */ -/* { dg-final { scan-tree-dump-times "vectorized 4 loops" 1 "vect" { target vect_fully_masked } } } */ -/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" { target { ! vect_fully_masked } } } }*/ -/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "vect" { target vect_fully_masked } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { target { ! vect_partial_vectors } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 4 loops" 1 "vect" { target vect_partial_vectors } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" { target { ! vect_partial_vectors } } } }*/ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "vect" { target vect_partial_vectors } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/slp-multitypes-11.c b/gcc/testsuite/gcc.dg/vect/slp-multitypes-11.c index 5200ed1cd94..96218861cd6 100644 --- a/gcc/testsuite/gcc.dg/vect/slp-multitypes-11.c +++ b/gcc/testsuite/gcc.dg/vect/slp-multitypes-11.c @@ -49,5 +49,7 @@ int main (void) } /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_unpack } } } */ -/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target vect_unpack xfail { vect_variable_length && vect_load_lanes } } } } */ +/* The epilogues are vectorized using partial vectors. */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { vect_unpack && {! vect_partial_vectors_usage_1 } } xfail { vect_variable_length && vect_load_lanes } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target { vect_unpack && vect_partial_vectors_usage_1 } xfail { vect_variable_length && vect_load_lanes } } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/slp-perm-1.c b/gcc/testsuite/gcc.dg/vect/slp-perm-1.c index ca7803ec1a9..4128cca024c 100644 --- a/gcc/testsuite/gcc.dg/vect/slp-perm-1.c +++ b/gcc/testsuite/gcc.dg/vect/slp-perm-1.c @@ -80,7 +80,9 @@ int main (int argc, const char* argv[]) } /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_perm } } } */ -/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { vect_perm3_int && {! vect_load_lanes } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { vect_perm3_int && { {! vect_load_lanes } && {! vect_partial_vectors_usage_1 } } } } } } */ +/* The epilogues are vectorized using partial vectors. */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target { vect_perm3_int && { {! vect_load_lanes } && vect_partial_vectors_usage_1 } } } } } */ /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target vect_load_lanes } } } */ /* { dg-final { scan-tree-dump "Built SLP cancelled: can use load/store-lanes" "vect" { target { vect_perm3_int && vect_load_lanes } } } } */ /* { dg-final { scan-tree-dump "LOAD_LANES" "vect" { target vect_load_lanes } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/slp-perm-5.c b/gcc/testsuite/gcc.dg/vect/slp-perm-5.c index b86a3dc8756..b137821ec39 100644 --- a/gcc/testsuite/gcc.dg/vect/slp-perm-5.c +++ b/gcc/testsuite/gcc.dg/vect/slp-perm-5.c @@ -104,7 +104,9 @@ int main (int argc, const char* argv[]) } /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_perm } } } */ -/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target { vect_perm3_int && { ! vect_load_lanes } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target { vect_perm3_int && { {! vect_load_lanes } && {! vect_partial_vectors_usage_1 } } } } } } */ +/* The epilogues are vectorized using partial vectors. */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "vect" { target { vect_perm3_int && { {! vect_load_lanes } && vect_partial_vectors_usage_1 } } } } } */ /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target vect_load_lanes } } } */ /* { dg-final { scan-tree-dump "Built SLP cancelled: can use load/store-lanes" "vect" { target { vect_perm3_int && vect_load_lanes } } } } */ /* { dg-final { scan-tree-dump "LOAD_LANES" "vect" { target vect_load_lanes } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/slp-perm-6.c b/gcc/testsuite/gcc.dg/vect/slp-perm-6.c index 97a0ebffe01..38489291a26 100644 --- a/gcc/testsuite/gcc.dg/vect/slp-perm-6.c +++ b/gcc/testsuite/gcc.dg/vect/slp-perm-6.c @@ -103,7 +103,9 @@ int main (int argc, const char* argv[]) } /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_perm } } } */ -/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target { vect_perm3_int && { ! vect_load_lanes } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target { vect_perm3_int && { {! vect_load_lanes } && {! vect_partial_vectors_usage_1 } } } } } } */ +/* The epilogues are vectorized using partial vectors. */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "vect" { target { vect_perm3_int && { {! vect_load_lanes } && vect_partial_vectors_usage_1 } } } } } */ /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target vect_load_lanes } } } */ /* { dg-final { scan-tree-dump "Built SLP cancelled: can use load/store-lanes" "vect" { target { vect_perm3_int && vect_load_lanes } } } } */ /* { dg-final { scan-tree-dump "LOAD_LANES" "vect" { target vect_load_lanes } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/slp-perm-7.c b/gcc/testsuite/gcc.dg/vect/slp-perm-7.c index 346411fd504..498999ac56e 100644 --- a/gcc/testsuite/gcc.dg/vect/slp-perm-7.c +++ b/gcc/testsuite/gcc.dg/vect/slp-perm-7.c @@ -96,7 +96,9 @@ int main (int argc, const char* argv[]) } /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_perm } } } */ -/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { vect_perm3_int && { ! vect_load_lanes } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { vect_perm3_int && { {! vect_load_lanes } && {! vect_partial_vectors_usage_1 } } } } } } */ +/* The epilogues are vectorized using partial vectors. */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target { vect_perm3_int && { {! vect_load_lanes } && vect_partial_vectors_usage_1 } } } } } */ /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target vect_load_lanes } } } */ /* { dg-final { scan-tree-dump "Built SLP cancelled: can use load/store-lanes" "vect" { target { vect_perm3_int && vect_load_lanes } } } } */ /* { dg-final { scan-tree-dump "LOAD_LANES" "vect" { target vect_load_lanes } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/slp-perm-8.c b/gcc/testsuite/gcc.dg/vect/slp-perm-8.c index 17aa111437a..9e59832fb8b 100644 --- a/gcc/testsuite/gcc.dg/vect/slp-perm-8.c +++ b/gcc/testsuite/gcc.dg/vect/slp-perm-8.c @@ -60,7 +60,9 @@ int main (int argc, const char* argv[]) } /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_perm_byte } } } } */ -/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { vect_perm3_byte && { ! vect_load_lanes } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { vect_perm3_byte && { { ! vect_load_lanes } && {! vect_partial_vectors_usage_1 } } } } } } */ +/* The epilogues are vectorized using partial vectors. */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target { vect_perm3_byte && { { ! vect_load_lanes } && vect_partial_vectors_usage_1 } } } } } */ /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target vect_load_lanes } } } */ /* { dg-final { scan-tree-dump "Built SLP cancelled: can use load/store-lanes" "vect" { target { vect_perm3_byte && vect_load_lanes } } } } */ /* { dg-final { scan-tree-dump "LOAD_LANES" "vect" { target vect_load_lanes } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/slp-perm-9.c b/gcc/testsuite/gcc.dg/vect/slp-perm-9.c index c54420abd9d..ab75f44eb75 100644 --- a/gcc/testsuite/gcc.dg/vect/slp-perm-9.c +++ b/gcc/testsuite/gcc.dg/vect/slp-perm-9.c @@ -61,7 +61,9 @@ int main (int argc, const char* argv[]) /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_perm_short || vect_load_lanes } } } } */ /* We don't try permutes with a group size of 3 for variable-length vectors. */ -/* { dg-final { scan-tree-dump-times "permutation requires at least three vectors" 1 "vect" { target { vect_perm_short && { ! vect_perm3_short } } xfail vect_variable_length } } } */ +/* { dg-final { scan-tree-dump-times "permutation requires at least three vectors" 1 "vect" { target { vect_perm_short && { { ! vect_perm3_short } && { ! vect_partial_vectors_usage_1 } } } xfail vect_variable_length } } } */ +/* Try to vectorize the epilogue using partial vectors. */ +/* { dg-final { scan-tree-dump-times "permutation requires at least three vectors" 2 "vect" { target { vect_perm_short && { { ! vect_perm3_short } && vect_partial_vectors_usage_1 } } xfail vect_variable_length } } } */ /* { dg-final { scan-tree-dump-not "permutation requires at least three vectors" "vect" { target vect_perm3_short } } } */ /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target { { ! vect_perm3_short } || vect_load_lanes } } } } */ /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { vect_perm3_short && { ! vect_load_lanes } } } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-version-2.c b/gcc/testsuite/gcc.dg/vect/vect-version-2.c index 0ea39e31801..7d3fb722f47 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-version-2.c +++ b/gcc/testsuite/gcc.dg/vect/vect-version-2.c @@ -17,4 +17,8 @@ void foo (double *x, double *y, int m, int n, int o, int p) } } -/* { dg-final { scan-tree-dump "reusing loop version created by if conversion" "vect" } } */ +/* Vectorization using partial vectors has zero versioning_threshold with + either usage 1 or usage 2, the cond_expr replies on the computation in + outer loop, so it doesn't need to reuse the loop version created by if + conversion. */ +/* { dg-final { scan-tree-dump "reusing loop version created by if conversion" "vect" {target {! vect_partial_vectors } } } } */ diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index f3fc5b80aea..46e8cddbcca 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -7081,6 +7081,67 @@ proc check_effective_target_vect_fully_masked { } { || [istarget amdgcn*-*-*] }] } +# Return true if the target supports the @code{len_load} and +# @code{len_store} optabs. + +proc check_effective_target_vect_len_load_store { } { + return 0 +} + +# Return the value of parameter vect-partial-vector-usage specified for +# target by checking the output of "-Q --help=params". Return zero if +# the desirable pattern isn't found. + +proc check_vect_partial_vector_usage { } { + global tool + + return [check_cached_effective_target vect_partial_vector_usage { + set result [check_compile vect_partial_vector_usage assembly { + int i; + } "-Q --help=params" ] + + # Get compiler emitted messages and delete generated file. + set lines [lindex $result 0] + set output [lindex $result 1] + remote_file build delete $output + + set pattern {=vect-partial-vector-usage=<0,2>\s+([0-2])} + # Capture the usage value to val, set it to zero if not found. + if { ![regexp $pattern $lines whole val] } then { + set val 0 + } + + return $val + }] +} + +# Return true if the target supports loop vectorization with partial vectors +# and @code{vect-partial-vector-usage} is set to 1. + +proc check_effective_target_vect_partial_vectors_usage_1 { } { + return [expr { ([check_effective_target_vect_fully_masked] + || [check_effective_target_vect_len_load_store]) + && [check_vect_partial_vector_usage] == 1 }] +} + +# Return true if the target supports loop vectorization with partial vectors +# and @code{vect-partial-vector-usage} is set to 2. + +proc check_effective_target_vect_partial_vectors_usage_2 { } { + return [expr { ([check_effective_target_vect_fully_masked] + || [check_effective_target_vect_len_load_store]) + && [check_vect_partial_vector_usage] == 2 }] +} + +# Return true if the target supports loop vectorization with partial vectors +# and @code{vect-partial-vector-usage} is nonzero. + +proc check_effective_target_vect_partial_vectors { } { + return [expr { ([check_effective_target_vect_fully_masked] + || [check_effective_target_vect_len_load_store]) + && [check_vect_partial_vector_usage] != 0 }] +} + # Return 1 if the target doesn't prefer any alignment beyond element # alignment during vectorization. -- 2.30.2