public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 0/14+2][Vectorizer] Made reductions endianness-neutral, fixes PR/61114
@ 2014-09-18 11:41 Alan Lawrence
  2014-09-18 11:45 ` [PATCH 1/14][AArch64] Temporarily remove aarch64_gimple_fold_builtin code for reduction operations Alan Lawrence
                   ` (16 more replies)
  0 siblings, 17 replies; 52+ messages in thread
From: Alan Lawrence @ 2014-09-18 11:41 UTC (permalink / raw)
  To: gcc-patches

The end goal here is to remove this code from tree-vect-loop.c 
(vect_create_epilog_for_reduction):

       if (BYTES_BIG_ENDIAN)
         bitpos = size_binop (MULT_EXPR,
                              bitsize_int (TYPE_VECTOR_SUBPARTS (vectype) - 1),
                              TYPE_SIZE (scalar_type));
       else

as this is the root cause of PR/61114 (see testcase there, failing on all 
bigendian targets supporting reduc_[us]plus_optab). Quoting Richard Biener, "all 
code conditional on BYTES/WORDS_BIG_ENDIAN in tree-vect* is suspicious". The 
code snippet above is used on two paths:

(Path 1) (patches 1-6) Reductions using REDUC_(PLUS|MIN|MAX)_EXPR = 
reduc_[us](plus|min|max)_optab.
The optab is documented as "the scalar result is stored in the least significant 
bits of operand 0", but the tree code as "the first element in the vector 
holding the result of the reduction of all elements of the operand". This 
mismatch means that when the tree code is folded, the code snippet above reads 
the result from the wrong end of the vector.

The strategy (as per https://gcc.gnu.org/ml/gcc-patches/2014-08/msg00041.html) 
is to define new tree codes and optabs that produce scalar results directly; 
this seems better than tying (the element of the vector into which the result is 
placed) to (the endianness of the target), and avoids generating extra moves on 
current bigendian targets. However, the previous optabs are retained for now as 
a migration strategy so as not to break existing backends; moving individual 
platforms over will follow.

A complication here is on AArch64, where we directly generate REDUC_PLUS_EXPRs 
from intrinsics in gimple_fold_builtin; I temporarily remove this folding in 
order to decouple the midend and AArch64 backend.

(Path 2) (patches 7-13) Reductions using whole-vector-shifts, i.e. 
VEC_RSHIFT_EXPR and vec_shr_optab. Here the tree code as well as the optab is 
defined in an endianness-dependent way, leading to significant complication in 
fold-const.c. (Moreover, the "equivalent" vec_shl_optab is never used!). Few 
platforms appear to handle vec_shr_optab (and fewer bigendian - I see only 
PowerPC and MIPS), so it seems pertinent to change the existing optab to be 
endianness-neutral.

Patch 10 defines vec_shr for AArch64, for the old specification; patch 13 
updates that implementation to fit the new endianness-neutral specification, 
serving as a guide for other existing backends. Patches/RFCs 15 and 16 are 
equivalents for MIPS and PowerPC; I haven't tested these but hope they act as 
useful pointers for the port maintainers.

Finally patch 14 cleans up the affected part of tree-vect-loop.c 
(vect_create_epilog_for_reduction).

--Alan

^ permalink raw reply	[flat|nested] 52+ messages in thread

end of thread, other threads:[~2014-11-14 17:21 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-18 11:41 [PATCH 0/14+2][Vectorizer] Made reductions endianness-neutral, fixes PR/61114 Alan Lawrence
2014-09-18 11:45 ` [PATCH 1/14][AArch64] Temporarily remove aarch64_gimple_fold_builtin code for reduction operations Alan Lawrence
2014-09-24  9:41   ` Marcus Shawcroft
2014-09-18 11:51 ` [PATCH 2/14][Vectorizer] Make REDUC_xxx_EXPR tree codes produce a scalar result Alan Lawrence
2014-09-22 10:34   ` Richard Biener
2014-09-22 13:23     ` Alan Lawrence
2014-09-24 15:02     ` Alan Lawrence
2014-09-24 18:08       ` Segher Boessenkool
2014-09-25 16:07         ` Alan Lawrence
2014-09-18 11:54 ` [PATCH 3/14] Add new optabs for reducing vectors to scalars Alan Lawrence
2014-09-22 10:40   ` Richard Biener
2014-09-22 13:26     ` Alan Lawrence
2014-09-22 13:38       ` Richard Biener
2014-09-25 14:33         ` [PATCH/RFC v2 " Alan Lawrence
2014-09-25 15:31           ` Richard Biener
2014-09-25 16:12             ` Alan Lawrence
2014-09-25 19:20               ` Segher Boessenkool
2014-09-18 11:59 ` [PATCH 4/14][AArch64] Use new reduc_plus_scal optabs, inc. for __builtins Alan Lawrence
2014-09-24  9:44   ` Marcus Shawcroft
2014-09-18 12:02 ` [PATCH 5/14][AArch64] Use new reduc_[us](min|max)_scal optabs, inc. for builtins Alan Lawrence
2014-09-24  9:47   ` Marcus Shawcroft
2014-09-18 12:05 ` [PATCH 6/14][AArch64] Restore gimple_folding of reduction intrinsics Alan Lawrence
2014-09-24  9:48   ` Marcus Shawcroft
2014-09-18 12:19 ` [PATCH 7/14][Testsuite] Add tests of reductions using whole-vector-shifts (multiplication) Alan Lawrence
2014-09-22 10:41   ` Richard Biener
2014-09-18 12:25 ` [PATCH 8/14][Testsuite] Add tests of reductions using whole-vector-shifts (ior) Alan Lawrence
2014-09-22 10:42   ` Richard Biener
2014-09-18 12:27 ` [PATCH 9/14] Enforce whole-vector-shifts to always be by a whole number of elements Alan Lawrence
2014-09-22 10:50   ` Richard Biener
2014-09-18 12:34 ` [PATCH 10/14][AArch64] Implement vec_shr optab Alan Lawrence
2014-09-18 12:35 ` [PATCH 11/14] Remove VEC_LSHIFT_EXPR and vec_shl_optab Alan Lawrence
2014-09-22 10:52   ` Richard Biener
2014-10-27 18:45     ` Alan Lawrence
2014-10-27 20:24       ` Richard Biener
2014-09-18 12:43 ` [PATCH 12/14][Vectorizer] Redefine VEC_RSHIFT_EXPR and vec_shr_optab as endianness-neutral Alan Lawrence
2014-09-18 13:12   ` David Edelsohn
2014-09-22 13:27     ` Bill Schmidt
2014-09-22 10:58   ` Richard Biener
2014-09-18 12:45 ` [PATCH 13/14][AArch64_be] Fix vec_shr pattern to correctly implement endianness-neutral optab Alan Lawrence
2014-09-22 10:52   ` Richard Biener
2014-09-18 12:48 ` [PATCH 14/14][Vectorizer] Tidy up vect_create_epilog / use_scalar_result Alan Lawrence
2014-09-22 10:53   ` Richard Biener
2014-11-14 17:29     ` PUSHED: " Alan Lawrence
2014-09-18 12:58 ` [PATCH/RFC 15 / 14+2][RS6000] Remove vec_shl and (hopefully) fix vec_shr Alan Lawrence
2014-09-23 12:50   ` David Edelsohn
2014-09-18 13:02 ` [PATCH 16 / 14+2][MIPS] " Alan Lawrence
2014-09-22 11:21 ` [PATCH 0/14+2][Vectorizer] Made reductions endianness-neutral, fixes PR/61114 Richard Biener
2014-09-22 11:26   ` Richard Biener
2014-10-06 17:31   ` Alan Lawrence
     [not found]   ` <5432D1A5.6080208@arm.com>
2014-10-07  7:45     ` Richard Biener
2014-10-07  7:46       ` Richard Biener
     [not found]       ` <5436C138.50208@arm.com>
2014-10-09 17:13         ` Alan Lawrence

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).