Re: [PATCH] RISC-V: strcpy size optimized: do not compile unreacheble code
Jeff Johnston <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <CAOox84uSvFRVG_S+rFw+JNa7Pbbkp6Cv_1R5n-JmGu8Wj-m3Sg@mail.gmail.com> |
Hi Alexey, Could you please reformat the condition to avoid double negatives? -- Jeff J. On Mon, Aug 25, 2025 at 8:20 AM Alexey Lapshin <[email protected]> wrote: > If misaligned access is allowed on the target machine, there is no need > to compile the byte-to-byte copy loop at the end of the strcpy function. > All bytes are already in place due to the earlier logic. > > Signed-off-by: Konstantin Kondrashov <[email protected]> > --- > newlib/libc/machine/riscv/rv_string.h | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/newlib/libc/machine/riscv/rv_string.h > b/newlib/libc/machine/riscv/rv_string.h > index dc2a26daf..9f5eb4099 100644 > --- a/newlib/libc/machine/riscv/rv_string.h > +++ b/newlib/libc/machine/riscv/rv_string.h > @@ -112,6 +112,8 @@ static __inline char *__libc_strcpy(char *dst, const > char *src, bool ret_start) > } > #endif /* not PREFER_SIZE_OVER_SPEED */ > > +#if !(!defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) && > + !(__riscv_misaligned_slow || __riscv_misaligned_fast)) > char ch; > do > { > @@ -122,6 +124,7 @@ static __inline char *__libc_strcpy(char *dst, const > char *src, bool ret_start) > } while (ch); > > return ret_start ? dst0 : dst - 1; > +#endif > } > > > -- > 2.43.0 > >