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

2022-09-09 Thread Jan-Benedict Glaw
Hi! On Wed, 2022-09-07 14:00:25 +0200, Richard Biener wrote: > On Wed, Sep 7, 2022 at 12:58 PM Jan-Benedict Glaw wrote: > > ../../gcc/gcc/tree-ssa-forwprop.cc:1258:42: error: array subscript 1 is > > outside array bounds of 'tree_node* [1]' [-Werror=array-bounds] > > 1258 | op[i -

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

2022-09-07 Thread Richard Biener via Gcc-patches
On Wed, Sep 7, 2022 at 12:58 PM Jan-Benedict Glaw wrote: > > Hi! > > On Wed, 2022-07-13 09:50:14 -0700, H.J. Lu via Gcc-patches > 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. > > > >

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

2022-09-07 Thread Jan-Benedict Glaw
Hi! On Wed, 2022-07-13 09:50:14 -0700, H.J. Lu via Gcc-patches 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; > } >

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

2022-07-14 Thread H.J. Lu via Gcc-patches
On Wed, Jul 13, 2022 at 11:42 PM Richard Biener wrote: > > On Wed, Jul 13, 2022 at 6:50 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) > > { > >r

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

2022-07-13 Thread Richard Biener via Gcc-patches
On Wed, Jul 13, 2022 at 6:50 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 > > in

[PATCH v3] Simplify memchr with small constant strings

2022-07-13 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; }