[Bug target/116999] Fold SVE whilele comparisons with max int value to ptrue
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Mar 5 08:26:20 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116999
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Richard Sandiford
<rsandifo@gcc.gnu.org>:
https://gcc.gnu.org/g:591e34c1f7bbaa6ac1046ec45f7d162fdb33a1de
commit r13-9411-g591e34c1f7bbaa6ac1046ec45f7d162fdb33a1de
Author: Richard Sandiford <richard.sandiford@arm.com>
Date: Wed Mar 5 08:25:54 2025 +0000
aarch64: Fix folding of degenerate svwhilele case [PR117045]
The svwhilele folder mishandled the degenerate case in which
the second argument is the maximum integer. In that case,
the result is all-true regardless of the first parameter:
If the second scalar operand is equal to the maximum signed integer
value then a condition which includes an equality test can never fail
and the result will be an all-true predicate.
This is because the conceptual "increment the first operand
by 1 after each element" is done modulo the range of the operand.
The GCC code was instead treating it as infinite precision.
whilele_5.c even had a test for the incorrect behaviour.
The easiest fix seemed to be to handle that case specially before
doing constant folding. This also copes with variable first operands.
gcc/
PR target/116999
PR target/117045
* config/aarch64/aarch64-sve-builtins-base.cc
(svwhilelx_impl::fold): Check for WHILELTs of the minimum value
and WHILELEs of the maximum value. Fold them to all-false and
all-true respectively.
gcc/testsuite/
PR target/116999
PR target/117045
* gcc.target/aarch64/sve/acle/general/whilele_5.c: Fix bogus
expected result.
* gcc.target/aarch64/sve/acle/general/whilele_11.c: New test.
* gcc.target/aarch64/sve/acle/general/whilele_12.c: Likewise.
(cherry picked from commit 50e7c51b0a0e9dc1d93f829016ae743b4f2e5070)
More information about the Gcc-bugs
mailing list