]> git.ipfire.org Git - thirdparty/gcc.git/commit
SVE intrinsics: Fold svdiv with all-zero operands to zero vector
authorJennifer Schmitz <jschmitz@nvidia.com>
Mon, 2 Sep 2024 13:46:57 +0000 (06:46 -0700)
committerJennifer Schmitz <jschmitz@nvidia.com>
Tue, 17 Sep 2024 06:33:24 +0000 (08:33 +0200)
commite311dd13a9adbc51d56971cba06e1ff15a4256d2
tree51d6d2561833fbbb1e387eb1bd48d03440577bea
parent008f4510d7c073509a676899c3887b2ec7517233
SVE intrinsics: Fold svdiv with all-zero operands to zero vector

This patch folds svdiv where one of the operands is all-zeros to a zero
vector, if one of the following conditions holds:
- the dividend is all zeros or
- the divisor is all zeros, and the predicate is ptrue or the predication
is _x or _z.
This case was not covered by the recent patch that implemented constant
folding, because that covered only cases where both operands are
constant vectors. Here, the operation is folded as soon as one of the operands
is a constant zero vector.
Folding of divison by 0 to return 0 is in accordance with
the semantics of sdiv and udiv.

The patch was bootstrapped and regtested on aarch64-linux-gnu, no regression.
OK for mainline?

Signed-off-by: Jennifer Schmitz <jschmitz@nvidia.com>
gcc/
* config/aarch64/aarch64-sve-builtins-base.cc (svdiv_impl::fold):
Add folding of all-zero operands to zero vector.

gcc/testsuite/
* gcc.target/aarch64/sve/fold_div_zero.c: New test.
* gcc.target/aarch64/sve/const_fold_div_1.c: Adjust expected
outcome.
gcc/config/aarch64/aarch64-sve-builtins-base.cc
gcc/testsuite/gcc.target/aarch64/sve/const_fold_div_1.c
gcc/testsuite/gcc.target/aarch64/sve/fold_div_zero.c [new file with mode: 0644]