This patch implements constant folding for svdiv. If the predicate is
ptrue or predication is _x, it uses vector_const_binop with
aarch64_const_binop as callback and tree_code TRUNC_DIV_EXPR to fold constant
integer operands.
In aarch64_const_binop, a case was added for TRUNC_DIV_EXPR to return 0
for division by 0, as defined in the semantics for svdiv.
Tests were added to check the produced assembly for different
predicates, signed and unsigned integers, and the svdiv_n_* case.

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):
        Try constant folding.
        * config/aarch64/aarch64-sve-builtins.cc (aarch64_const_binop):
        Add special case for division by 0.

gcc/testsuite/
        * gcc.target/aarch64/sve/const_fold_div_1.c: New test.

Attachment: 0002-SVE-intrinsics-Fold-constant-operands-for-svdiv.patch
Description: Binary data

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

Reply via email to