On Mon, Jan 31, 2022 at 5:26 PM Tom de Vries <tdevr...@suse.de> wrote: > > [ was: Re: [RFC] ldist: Recognize rawmemchr loop patterns ] > > On 1/31/22 16:00, Richard Biener wrote: > >> I'm running into PR56888 ( > >> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56888 ) on nvptx due to > >> this, f.i. in gcc/testsuite/gcc.c-torture/execute/builtins/strlen.c, > >> where gcc/testsuite/gcc.c-torture/execute/builtins/lib/strlen.c contains > >> a strlen function, with a strlen loop, which is transformed by > >> pass_loop_distribution into a __builtin_strlen, which is then expanded > >> into a strlen call, creating a self-recursive function. [ And on nvptx, > >> that happens to result in a compilation failure, which is how I found > >> this. ] > >> > >> According to this ( > >> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56888#c21 ) comment: > >> ... > >> -fno-tree-loop-distribute-patterns is the reliable way to not > >> transform loops into library calls. > >> ... > >> > >> Then should we have something along the lines of: > >> ... > >> $ git diff > >> diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c > >> index 6fe59cd56855..9a211d30cd7e 100644 > >> --- a/gcc/tree-loop-distribution.c > >> +++ b/gcc/tree-loop-distribution.c > >> @@ -3683,7 +3683,11 @@ loop_distribution::transform_reduction_loop > >> && TYPE_PRECISION (ptr_type_node) >= 32) > >> || (TYPE_OVERFLOW_UNDEFINED (reduction_var_type) > >> && TYPE_PRECISION (reduction_var_type) <= > >> TYPE_PRECISION (sizetype))) > >> - && builtin_decl_implicit (BUILT_IN_STRLEN)) > >> + && builtin_decl_implicit (BUILT_IN_STRLEN) > >> + && flag_tree_loop_distribute_patterns) > >> generate_strlen_builtin (loop, reduction_var, load_iv.base, > >> reduction_iv.base, loc); > >> else if (direct_optab_handler (rawmemchr_optab, TYPE_MODE > >> (load_type)) > >> ... > >> ? > >> > >> Or is the comment no longer valid? > > > > It is still valid - and yes, I think we need to guard it with this flag > > but please do it in the caller to transform_reduction_loop. > > Done. > > Ok for trunk?
OK. > Thanks, > - Tom