aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.cc
diff options
context:
space:
mode:
authorJennifer Schmitz <jschmitz@nvidia.com>2024-08-30 07:03:49 -0700
committerJennifer Schmitz <jschmitz@nvidia.com>2024-09-03 09:23:19 +0200
commitee8b7231b03a36dfc09d94f2b663636ca2a36daf (patch)
tree7ae240c76346e9897821af38f58b8ba2bcac9fff /gcc/fold-const.cc
parent87217bea3aa556779a111cec0ef45dcefd1736f6 (diff)
downloadgcc-ee8b7231b03a36dfc09d94f2b663636ca2a36daf.zip
gcc-ee8b7231b03a36dfc09d94f2b663636ca2a36daf.tar.gz
gcc-ee8b7231b03a36dfc09d94f2b663636ca2a36daf.tar.bz2
SVE intrinsics: Fold constant operands for svdiv.
This patch implements constant folding for svdiv: The new function aarch64_const_binop was created, which - in contrast to int_const_binop - does not treat operations as overflowing. This function is passed as callback to vector_const_binop from the new gimple_folder method fold_const_binary, if the predicate is ptrue or predication is _x. From svdiv_impl::fold, fold_const_binary is called with TRUNC_DIV_EXPR as tree_code. 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 <jschmitz@nvidia.com> gcc/ * config/aarch64/aarch64-sve-builtins-base.cc (svdiv_impl::fold): Try constant folding. * config/aarch64/aarch64-sve-builtins.h: Declare gimple_folder::fold_const_binary. * config/aarch64/aarch64-sve-builtins.cc (aarch64_const_binop): New function to fold binary SVE intrinsics without overflow. (gimple_folder::fold_const_binary): New helper function for constant folding of SVE intrinsics. gcc/testsuite/ * gcc.target/aarch64/sve/const_fold_div_1.c: New test.
Diffstat (limited to 'gcc/fold-const.cc')
0 files changed, 0 insertions, 0 deletions