On Tue, Nov 15, 2022 at 1:46 AM Kito Cheng wrote: > Hi Christoph: > > > This patch implements expansions for the cmpstrsi and the cmpstrnsi > > builtins using Zbb instructions (if available). > > This allows to inline calls to strcmp() and strncmp(). > > > > The expansion basically emits a peeled comparison sequence (i.e. a peeled > > comparison loop) which compares XLEN bits per step if possible. > > > > The emitted sequence can be controlled, by setting the maximum number > > of compared bytes (-mstring-compare-inline-limit). > > I would like to have a unified option interface, > maybe -m[no-]inline-str[n]cmp and -minline-str[n]cmp-limit. > Ok, I don't mind (in fact, I thought about this as well). The reason why it is how it is: I took inspiration from the rs6000 backend. > And add some option like this: > -minline-str[n]cmp=[bitmanip|vector|auto] in future, > 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. >