public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [0/5] Don't defer vector type choice for bools (PR 92596)
@ 2019-11-29 10:11 Richard Sandiford
  2019-11-29 10:13 ` [1/5] Improve tree-vect-patterns.c handling of boolean comparisons Richard Sandiford
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Richard Sandiford @ 2019-11-29 10:11 UTC (permalink / raw)
  To: gcc-patches

When vectorising a comparison between N-bit integers or N-bit floats,
we want the boolean result to use the vector mask type for N-bit elements.
On most targets this is a vector of N-bit integers, but for SVE it's
a vector predicate and on AVX512 it's a scalar integer mask.

On the other hand, when loading or storing an M-byte boolean, we want to
treat it like any other M-byte integer type.

This difference leads to some complicated handling.  E.g. booleean logic
ops fed by two N-bit comparisons should use a vector mask for N-bit
elements.  But boolean logic ops fed by two M-byte data loads should
use normal M-byte integer vectors.  Boolean logic ops fed by an N-bit
comparison and an M-bit comparison need to convert one of the inputs
first (handled via pattern stmts).  Boolean logic ops fed by an N-bit
comparison and a load are not yet supported.  Etc.

Historically we've tried to make this choice on the fly.  This has
two major downsides:

(a) search_type_for_mask has to use a worklist to find the mask type for
    a particular operation.  The results are not cached between calls,
    so this is a potential source of quadratic behavior.

(b) we can only choose the vector type for a boolean result once
    we know the vector types of the inputs.  So both the loop and
    SLP vectorisers make another pass for boolean types.

The second example in PR 92596 is another case in which (b) causes
problems.  I tried various non-invasive ways of working around it,
but although they worked for the testcase and testsuite, it was easy
to see that they were flaky and would probably cause problems later.
In the end I think the best fix is to stop trying to make this decision
on the fly and record it in the stmt_vec_info instead.

Obviously it's not ideal to be doing something like this in stage 3,
but it is a bug fix and I think it will make bool-related problems
easier to handle in future.

Each patch tested individually on aarch64-linux-gnu and the series
as a whole on x86_64-linux-gnu.  OK to install?

Richard

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

end of thread, other threads:[~2019-11-29 12:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-29 10:11 [0/5] Don't defer vector type choice for bools (PR 92596) Richard Sandiford
2019-11-29 10:13 ` [1/5] Improve tree-vect-patterns.c handling of boolean comparisons Richard Sandiford
2019-11-29 10:53   ` Richard Biener
2019-11-29 10:14 ` [2/5] Make vectorizable_operation punt early on codes it doesn't handle Richard Sandiford
2019-11-29 10:26   ` Richard Biener
2019-11-29 10:14 ` [3/5] Make vect_get_mask_type_for_stmt take a group size Richard Sandiford
2019-11-29 10:30   ` Richard Biener
2019-11-29 10:15 ` [4/5] Record the vector mask precision in stmt_vec_info Richard Sandiford
2019-11-29 10:34   ` Richard Biener
2019-11-29 10:25 ` [5/5] Don't defer choice of vector type for bools (PR 92596) Richard Sandiford
2019-11-29 12:58   ` Richard Biener

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).