aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authorStefan Schulze Frielinghaus <stefansf@linux.ibm.com>2021-10-11 09:59:13 +0200
committerStefan Schulze Frielinghaus <stefansf@linux.ibm.com>2021-10-11 09:59:13 +0200
commit6f966f06146be7689af471d152e18ff50c609d99 (patch)
tree72af686fdc3b931398a2f5837d57d2a364616302 /gcc/builtins.c
parent9abf8c9534144fe9b4948a3104655983821ca7a1 (diff)
downloadgcc-6f966f06146be7689af471d152e18ff50c609d99.zip
gcc-6f966f06146be7689af471d152e18ff50c609d99.tar.gz
gcc-6f966f06146be7689af471d152e18ff50c609d99.tar.bz2
ldist: Recognize strlen and rawmemchr like loops
This patch adds support for recognizing loops which mimic the behaviour of functions strlen and rawmemchr, and replaces those with internal function calls in case a target provides them. In contrast to the standard strlen and rawmemchr functions, this patch also supports different instances where the memory pointed to is interpreted as 8, 16, and 32-bit sized, respectively. gcc/ChangeLog: * builtins.c (get_memory_rtx): Change to external linkage. * builtins.h (get_memory_rtx): Add function prototype. * doc/md.texi (rawmemchr<mode>): Document. * internal-fn.c (expand_RAWMEMCHR): Define. * internal-fn.def (RAWMEMCHR): Add. * optabs.def (rawmemchr_optab): Add. * tree-loop-distribution.c (find_single_drs): Change return code behaviour by also returning true if no single store was found but a single load. (loop_distribution::classify_partition): Respect the new return code behaviour of function find_single_drs. (loop_distribution::execute): Call new function transform_reduction_loop in order to replace rawmemchr or strlen like loops by calls into builtins. (generate_reduction_builtin_1): New function. (generate_rawmemchr_builtin): New function. (generate_strlen_builtin_1): New function. (generate_strlen_builtin): New function. (generate_strlen_builtin_using_rawmemchr): New function. (reduction_var_overflows_first): New function. (determine_reduction_stmt_1): New function. (determine_reduction_stmt): New function. (loop_distribution::transform_reduction_loop): New function. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/ldist-rawmemchr-1.c: New test. * gcc.dg/tree-ssa/ldist-rawmemchr-2.c: New test. * gcc.dg/tree-ssa/ldist-strlen-1.c: New test. * gcc.dg/tree-ssa/ldist-strlen-2.c: New test. * gcc.dg/tree-ssa/ldist-strlen-3.c: New test.
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 80a1bb1..f1c3fea 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -105,7 +105,6 @@ builtin_info_type builtin_info[(int)END_BUILTINS];
bool force_folding_builtin_constant_p;
static int target_char_cast (tree, char *);
-static rtx get_memory_rtx (tree, tree);
static int apply_args_size (void);
static int apply_result_size (void);
static rtx result_vector (int, rtx);
@@ -1355,7 +1354,7 @@ expand_builtin_prefetch (tree exp)
the maximum length of the block of memory that might be accessed or
NULL if unknown. */
-static rtx
+rtx
get_memory_rtx (tree exp, tree len)
{
tree orig_exp = exp;