]> git.ipfire.org Git - thirdparty/gcc.git/commit
MATCH: Optimize `VEC_SHL_INSERT (dup (A), A)` to just `dup (A) [PR116075]
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Wed, 29 Oct 2025 18:58:31 +0000 (11:58 -0700)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Thu, 30 Oct 2025 15:19:01 +0000 (08:19 -0700)
commitfcde4c81644aecbb2b03f0b2f470a4d1116706cc
tree7c5ce4ac070d0ab403cc4e47cd603732c2c7b743
parent256fa1df0ed0e4ba955a1ea24b4b2b4a8325efa5
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>
gcc/fold-const-call.cc
gcc/match.pd
gcc/testsuite/gcc.target/aarch64/sve/dup-insr-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/dup-insr-2.c [new file with mode: 0644]