MATCH: Optimize `VEC_SHL_INSERT (dup (A), A)` to just `dup (A) [PR116075]
It was noticed if we have `.VEC_SHL_INSERT ({ 0, ... }, 0)` it was not being
simplified to just `{ 0, ... }`. This was generated from the autovectorizer
(maybe even on accident, see PR tree-optmization/116081).
This adds a few SVE testcases to see if this is optimized since the
auto-vectorizer or intrinsics are the only two ways of getting this
produced.
Changes since:
* v1: Move the constant case over to fold-const-call.cc.
Simplify match pattern to use handle vec_duplicate.
Build and tested for aarch64-linux-gnu with no regressions.
PR target/116075
gcc/ChangeLog:
* fold-const-call.cc (fold_const_vec_shl_insert): New function.
(fold_const_call): Call fold_const_vec_shl_insert for CFN_VEC_SHL_INSERT.
* match.pd (`VEC_SHL_INSERT (dup (A), A)`): New pattern.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/sve/dup-insr-1.c: New test.
* gcc.target/aarch64/sve/dup-insr-2.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>