Re: [PATCH v2] Simplify memchr with small constant strings

2022-07-13 Thread H.J. Lu via Gcc-patches
On Wed, Jul 13, 2022 at 5:35 AM Richard Biener wrote: > > On Tue, Jul 12, 2022 at 6:59 PM H.J. Lu wrote: > > > > On Fri, Jul 8, 2022 at 5:54 AM Richard Biener > > wrote: > > > > > > On Thu, Jul 7, 2022 at 6:45 PM H.J. Lu wrote: > > > > > > > > When memchr is applied on a constant string of no m

Re: [PATCH v2] Simplify memchr with small constant strings

2022-07-13 Thread Richard Biener via Gcc-patches
On Tue, Jul 12, 2022 at 6:59 PM H.J. Lu wrote: > > On Fri, Jul 8, 2022 at 5:54 AM Richard Biener > wrote: > > > > On Thu, Jul 7, 2022 at 6:45 PM H.J. Lu wrote: > > > > > > When memchr is applied on a constant string of no more than the bytes of > > > a word, simplify memchr by checking each byte

Re: [PATCH v2] Simplify memchr with small constant strings

2022-07-12 Thread H.J. Lu via Gcc-patches
On Fri, Jul 8, 2022 at 5:54 AM Richard Biener wrote: > > On Thu, Jul 7, 2022 at 6:45 PM H.J. Lu wrote: > > > > When memchr is applied on a constant string of no more than the bytes of > > a word, simplify memchr by checking each byte in the constant string. > > > > int f (int a) > > { > >retu

Re: [PATCH v2] Simplify memchr with small constant strings

2022-07-08 Thread Richard Biener via Gcc-patches
On Thu, Jul 7, 2022 at 6:45 PM H.J. Lu wrote: > > When memchr is applied on a constant string of no more than the bytes of > a word, simplify memchr by checking each byte in the constant string. > > int f (int a) > { >return __builtin_memchr ("AE", a, 2) != 0; > } > > is simplified to > > int

[PATCH v2] Simplify memchr with small constant strings

2022-07-07 Thread H.J. Lu via Gcc-patches
When memchr is applied on a constant string of no more than the bytes of a word, simplify memchr by checking each byte in the constant string. int f (int a) { return __builtin_memchr ("AE", a, 2) != 0; } is simplified to int f (int a) { return ((char) a == 'A' || (char) a == 'E') != 0; }