> > I would like to have a unified option interface, > > maybe -m[no-]inline-str[n]cmp and -minline-str[n]cmp-limit. > > For the basic option (-m[no-]inline-str[n]cmp), I would punt to > -fno-builtin-str[n]cmp.
-fno-bulitin-* will also suppress middle-end optimization for those builtins. see: https://github.com/gcc-mirror/gcc/blob/master/gcc/tree-ssa-strlen.cc#L5372 and https://github.com/gcc-mirror/gcc/blob/master/gcc/tree-loop-distribution.cc for -fno-bulitin-memcpy/memset/memmove > The limit-one sounds more like a --param? Use -param=inline-*-limit= sound good idea, aarch64 and x86 have few options like that. > > > And add some option like this: > > -minline-str[n]cmp=[bitmanip|vector|auto] in future, > > If we want to follow the lead of others, then x86 has a > -mstringop-strategy=alg Using same option name as x86 is SGTM. > > since I assume we'll have different versions of those things. > > > > > > > > gcc/ChangeLog: > > > > > > * config/riscv/riscv-protos.h (riscv_expand_strn_compare): New > > > prototype. > > > * config/riscv/riscv-string.cc (GEN_EMIT_HELPER3): New helper > > > macros. > > > (GEN_EMIT_HELPER2): New helper macros. > > > (expand_strncmp_zbb_sequence): New function. > > > (riscv_emit_str_compare_zbb): New function. > > > (riscv_expand_strn_compare): New function. > > > * config/riscv/riscv.md (cmpstrnsi): Invoke expansion functions > > > for strn_compare. > > > (cmpstrsi): Invoke expansion functions for strn_compare. > > > * config/riscv/riscv.opt: Add new parameter > > > '-mstring-compare-inline-limit'. > > > > We need to document this option.