[PATCH] riscv: Optimize memset

Andrew Jones ajones at ventanamicro.com
Tue May 9 23:58:22 PDT 2023


On Wed, May 10, 2023 at 11:52:43AM +0800, zhangfei wrote:
> From: zhangfei <zhangfei at nj.iscas.ac.cn>
> 
> On Tue, May 09, 2023 11:16:33AM +0200, Andrew Jones wrote: 
> > On Tue, May 09, 2023 at 10:22:07AM +0800, zhangfei wrote:
> > > 
> > > Hi,
> > > 
> > > I filled head and tail with minimal branching. Each conditional ensures that 
> > > all the subsequently used offsets are well-defined and in the dest region.
> > 
> > I know. You trimmed my comment, so I'll quote myself, here
> > 
> > """
> > After the check of a2 against 6 above we know that offsets 6(t0)
> > and -7(a3) are safe. Are we trying to avoid too may redundant
> > stores with these additional checks?
> > """
> > 
> > So, again. Why the additional check against 8 above and, the one you
> > trimmed, checking 10?
> 
> Hi,
> 
> These additional checks are to avoid too many redundant stores. 
> 
> Adding a check for more than 8 bytes is because after the loop 
> segment '3' comes out, the remaining bytes are less than 8 bytes, 
> which also avoids redundant stores.

So the benchmarks showed these additional checks were necessary to avoid
making memset worse? Please add comments to the code explaining the
purpose of the checks.

Thanks,
drew



More information about the linux-riscv mailing list