diff options
author | Richard Biener <rguenther@suse.de> | 2024-09-23 10:13:17 +0200 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2024-09-23 11:52:27 +0200 |
commit | 723f7b6db841c1a101a2f5b3b6273d8449dae39e (patch) | |
tree | 76276a953028929ec657d1eedc78ef8c39a2d810 /gcc | |
parent | dfb750798b07e7f412d52c22145ca8bce1911ac8 (diff) | |
download | gcc-723f7b6db841c1a101a2f5b3b6273d8449dae39e.zip gcc-723f7b6db841c1a101a2f5b3b6273d8449dae39e.tar.gz gcc-723f7b6db841c1a101a2f5b3b6273d8449dae39e.tar.bz2 |
tree-optimization/116791 - Elementwise SLP vectorization
The following restricts the elementwise SLP vectorization to the
single-lane case which is the reason I enabled it to avoid regressions
with non-SLP. The PR shows that multi-line SLP loads with elementwise
accesses require work, I'll open a new bug to track this for the
future.
PR tree-optimization/116791
* tree-vect-stmts.cc (get_group_load_store_type): Only
fall back to elementwise access for single-lane SLP, restore
hard failure mode for other cases.
* gcc.dg/vect/pr116791.c: New testcase.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/pr116791.c | 20 | ||||
-rw-r--r-- | gcc/tree-vect-stmts.cc | 23 |
2 files changed, 37 insertions, 6 deletions
diff --git a/gcc/testsuite/gcc.dg/vect/pr116791.c b/gcc/testsuite/gcc.dg/vect/pr116791.c new file mode 100644 index 0000000..d9700a8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr116791.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-mavx2" { target avx2 } } */ + +struct nine_context { + unsigned tex_stage[8][33]; +}; +struct fvec4 { + float x[2]; +}; +void f(struct fvec4 *dst, struct nine_context *context) +{ + unsigned s; + for (s = 0; s < 8; ++s) + { + float *rgba = &dst[s].x[0]; + unsigned color = context->tex_stage[s][0]; + rgba[0] = (float)((color >> 16) & 0xFF) / 0xFF; + rgba[1] = (float)((color >> 8) & 0xFF) / 0xFF; + } +} diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index b72b54d..ad08fbe 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -2190,12 +2190,23 @@ get_group_load_store_type (vec_info *vinfo, stmt_vec_info stmt_info, && single_element_p && maybe_gt (group_size, TYPE_VECTOR_SUBPARTS (vectype))) { - *memory_access_type = VMAT_ELEMENTWISE; - if (dump_enabled_p ()) - dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "single-element interleaving not supported " - "for not adjacent vector loads, using " - "elementwise access\n"); + if (SLP_TREE_LANES (slp_node) == 1) + { + *memory_access_type = VMAT_ELEMENTWISE; + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "single-element interleaving not supported " + "for not adjacent vector loads, using " + "elementwise access\n"); + } + else + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "single-element interleaving not supported " + "for not adjacent vector loads\n"); + return false; + } } } } |