diff options
author | Tamar Christina <tamar.christina@arm.com> | 2024-10-14 14:00:25 +0100 |
---|---|---|
committer | Tamar Christina <tamar.christina@arm.com> | 2024-10-14 14:00:25 +0100 |
commit | be966baa353dfcc20b76b5a5586ab2494bb0a735 (patch) | |
tree | bba9e37d713088829d26297e22c5409f54144bc5 /gcc/simplify-rtx.cc | |
parent | 306834b7f74ab61160f205e04f5bf35b71f9ec52 (diff) | |
download | gcc-be966baa353dfcc20b76b5a5586ab2494bb0a735.zip gcc-be966baa353dfcc20b76b5a5586ab2494bb0a735.tar.gz gcc-be966baa353dfcc20b76b5a5586ab2494bb0a735.tar.bz2 |
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.
Diffstat (limited to 'gcc/simplify-rtx.cc')
-rw-r--r-- | gcc/simplify-rtx.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/simplify-rtx.cc b/gcc/simplify-rtx.cc index dc0d192d..4d024ec 100644 --- a/gcc/simplify-rtx.cc +++ b/gcc/simplify-rtx.cc @@ -4088,10 +4088,10 @@ simplify_context::simplify_binary_operation_1 (rtx_code code, if (VECTOR_MODE_P (mode) && GET_CODE (op0) == ASHIFTRT && (CONST_INT_P (XEXP (op0, 1)) || (GET_CODE (XEXP (op0, 1)) == CONST_VECTOR - && CONST_VECTOR_DUPLICATE_P (XEXP (op0, 1)) + && const_vec_duplicate_p (XEXP (op0, 1)) && CONST_INT_P (XVECEXP (XEXP (op0, 1), 0, 0)))) && GET_CODE (op1) == CONST_VECTOR - && CONST_VECTOR_DUPLICATE_P (op1) + && const_vec_duplicate_p (op1) && CONST_INT_P (XVECEXP (op1, 0, 0))) { unsigned HOST_WIDE_INT shift_count |