[GCC, Vect] Fix costing for vector shifts
commite3126e5f649c8eebe07fc517d86f10d6867b7eec
authorSudakshina Das <sudi.das@arm.com>
Mon, 9 Dec 2019 10:22:01 +0000 (9 10:22 +0000)
committerSudakshina Das <sudi@gcc.gnu.org>
Mon, 9 Dec 2019 10:22:01 +0000 (9 10:22 +0000)
tree666f91365cb8eb2177a3b7b04ea599caacd740ca
parent49647b7b25673273262fb630598027c6d841690f
[GCC, Vect] Fix costing for vector shifts

While looking at the vectorization for following example, we realized that
even though vectorizable_shift function was distinguishing vector shifted
by vector from vector shifted by scalar, while modelling the cost it would
always add the cost of building a vector constant despite not needing it for
vector shifted by scalar.

This patch fixes this by using scalar_shift_arg to determine whether we need
to build a vector for the second operand or not. This causes the test case
below to now vectorize.

gcc/ChangeLog:

2019-12-09  Sudakshina Das  <sudi.das@arm.com>
    Richard Sandiford  <richard.sandiford@arm.com>

* tree-vect-stmt.c (vectorizable_shift): Condition ndts for
vect_model_simple_cost call on scalar_shift_arg.

gcc/testsuite/ChangeLog:

2019-12-09  Sudakshina Das  <sudi.das@arm.com>

* gcc.dg/vect/vect-shift-5.c: New test.

Co-Authored-By: Richard Sandiford <richard.sandiford@arm.com>
From-SVN: r279114
gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/vect-shift-5.c [new file with mode: 0644]
gcc/tree-vect-stmts.c