This patch folds svdiv where one of the operands is all-zeros to a zero
vector, if 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 <jschm...@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.

Attachment: 0001-SVE-intrinsics-Fold-svdiv-with-all-zero-operands-to-.patch
Description: Binary data

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to