]> git.ipfire.org Git - thirdparty/gcc.git/commit
simplify-rtx: Fix incorrect folding of shift and AND [PR117012]
authorTamar Christina <tamar.christina@arm.com>
Mon, 14 Oct 2024 13:00:25 +0000 (14:00 +0100)
committerTamar Christina <tamar.christina@arm.com>
Mon, 14 Oct 2024 13:00:25 +0000 (14:00 +0100)
commitbe966baa353dfcc20b76b5a5586ab2494bb0a735
treebba9e37d713088829d26297e22c5409f54144bc5
parent306834b7f74ab61160f205e04f5bf35b71f9ec52
simplify-rtx: Fix incorrect folding of shift and AND [PR117012]

The optimization added in r15-1047-g7876cde25cbd2f is using the wrong
operaiton to check for uniform constant vectors.

The Author intended to check that all the lanes in the vector are the same and
so used CONST_VECTOR_DUPLICATE_P.  However this only checks that the vector
is created from a pattern duplication, but doesn't say how many pattern
alternatives make up the duplication.  Normally would would need to check this
separately or use const_vec_duplicate_p.

Without this the optimization incorrectly triggers.

gcc/ChangeLog:

PR rtl-optimization/117012
* simplify-rtx.cc (simplify_context::simplify_binary_operation_1): Use
const_vec_duplicate_p instead of CONST_VECTOR_DUPLICATE_P.

gcc/testsuite/ChangeLog:

PR rtl-optimization/117012
* gcc.target/aarch64/pr117012.c: New test.
gcc/simplify-rtx.cc
gcc/testsuite/gcc.target/aarch64/pr117012.c [new file with mode: 0644]