middle-end: Add an RPO pass after successful vectorization
authorTamar Christina <tamar.christina@arm.com>
Wed, 10 Nov 2021 15:58:15 +0000 (15:58 +0000)
committerTamar Christina <tamar.christina@arm.com>
Wed, 10 Nov 2021 15:58:15 +0000 (15:58 +0000)
commit8ed62c929c7c44627f41627e085e15d77b2e6ed4
tree42dc3f70824bc9c9643bdbcb9826d1857972a15b
parenteaec20fde587e0695b100dcba5ff56944c3ae8c0
middle-end: Add an RPO pass after successful vectorization

Following my current SVE predicate optimization series a problem has presented
itself in that the way vector masks are generated for masked operations relies
on CSE to share masks efficiently.

The issue however is that masking is done using the & operand and & is
associative and so reassoc decides to reassociate the masked operations.

This makes CSE then unable to CSE an unmasked and a masked operation leading to
duplicate operations being performed.

To counter this we want to add an RPO pass over the vectorized loop body when
vectorization succeeds.  This makes it then no longer reliant on the RTL level
CSE.

I have not added a testcase for this as it requires the changes in my patch
series, however the entire series relies on this patch to work so all the
tests there cover it.

gcc/ChangeLog:

* tree-vectorizer.c (vectorize_loops): Do local CSE through RPVN upon
successful vectorization.
gcc/tree-vectorizer.c