This patch implements constant folding for svdiv. A new gimple_folder method was added that uses const_binop to fold binary operations using a given tree_code. For svdiv, this method is used to fold constant operands. Additionally, if at least one of the operands is a zero vector, svdiv is folded to a zero vector (in case of ptrue, _x, or _z). Tests were added to check the produced assembly for different predicates and signed and unsigned integers. Currently, constant folding is only implemented for integers and binary operations, but extending it to float types and other operations is planned for a future follow-up.
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 constant folding. * config/aarch64/aarch64-sve-builtins.cc (gimple_folder::const_fold): New method. * config/aarch64/aarch64-sve-builtins.h (gimple_folder::const_fold): Add function declaration. gcc/testsuite/ * gcc.target/aarch64/sve/const_fold_div_1.c: New test. * gcc.target/aarch64/sve/const_fold_div_zero.c: Likewise.
0001-SVE-intrinsics-Fold-constant-operands-for-svdiv.patch
Description: Binary data
smime.p7s
Description: S/MIME cryptographic signature