Re: Please review writeup for fixing PR 78809 (inline strcmp for small constant strings)

2017-11-20 Thread Qing Zhao
> On Nov 17, 2017, at 7:39 PM, Jeff Law wrote: > >>> >> >> thanks for the info, Martin. >> >> In my case, it’s the size of “100” cannot be collected in the >> MINMAXLEN[1] for the string “s”. >> >> I need to make sure that the size of variable string s is larger than >> the size of constant

Re: Please review writeup for fixing PR 78809 (inline strcmp for small constant strings)

2017-11-20 Thread Qing Zhao
> On Nov 17, 2017, at 7:32 PM, Jeff Law wrote: > > On 11/17/2017 03:45 PM, Qing Zhao wrote: do you think using this routine is good? or do you have other suggestions (since I am still not very familiar with the internals of GCC, might not find the best available one now…) >>> The

Re: Please review writeup for fixing PR 78809 (inline strcmp for small constant strings)

2017-11-20 Thread Qing Zhao
> On Nov 17, 2017, at 5:54 PM, Martin Sebor wrote: > >> >> for the safety checking purpose, when we try to convert >> >> __builtin_strcmp(s, "abc") != 0 >> >> to >> >> __builtin_memcmp (s, “abc”, 4) != 0 >> >> we have to make sure that the size of variable “s” is larger than “4”. > > Presu

Re: Please review writeup for fixing PR 78809 (inline strcmp for small constant strings)

2017-11-17 Thread Richard Biener
On November 17, 2017 11:20:45 PM GMT+01:00, Qing Zhao wrote: > >> On Nov 16, 2017, at 6:24 PM, Martin Sebor wrote: >>> >>> In my current local implementation, I used the following routine to >get the range info: (and use the MINMAXLEN[1]+1 for the length of the >non-constant string) >>> >>> /

Re: Please review writeup for fixing PR 78809 (inline strcmp for small constant strings)

2017-11-17 Thread Jeff Law
On 11/17/2017 03:20 PM, Qing Zhao wrote: > >> On Nov 16, 2017, at 6:24 PM, Martin Sebor > > wrote: >>> >>> In my current local implementation, I used the following routine to >>> get the range info:  (and use the MINMAXLEN[1]+1 for the length of >>> the non-constant string

Re: Please review writeup for fixing PR 78809 (inline strcmp for small constant strings)

2017-11-17 Thread Jeff Law
On 11/17/2017 03:50 PM, Qing Zhao wrote: >> >> The difficulty is tracking when exposure leads to these secondary >> opportunities. I often end up looking for this kind of stuff by first >> identifying many source files where the transformation applies. Then I >> generate dumps & assembly code fo

Re: Please review writeup for fixing PR 78809 (inline strcmp for small constant strings)

2017-11-17 Thread Jeff Law
On 11/17/2017 03:45 PM, Qing Zhao wrote: >>> do you think using this routine is good? or do you have other >>> suggestions (since I am still not very familiar with the internals of >>> GCC, might not find the best available one now…) >> The range information attached to an SSA_NAME is global data.

Re: Please review writeup for fixing PR 78809 (inline strcmp for small constant strings)

2017-11-17 Thread Martin Sebor
On 11/17/2017 04:08 PM, Qing Zhao wrote: On Nov 17, 2017, at 1:50 AM, Jakub Jelinek wrote: On Thu, Nov 16, 2017 at 06:14:35PM -0700, Jeff Law wrote: However, this routine currently miss a very obvious case as the following: char s[100] = {'a','b','c','d’}; __builtin_strcmp(s, "abc") != 0

Re: Please review writeup for fixing PR 78809 (inline strcmp for small constant strings)

2017-11-17 Thread Qing Zhao
> On Nov 17, 2017, at 1:50 AM, Jakub Jelinek wrote: > > On Thu, Nov 16, 2017 at 06:14:35PM -0700, Jeff Law wrote: >>> However, this routine currently miss a very obvious case as the following: >>> >>> char s[100] = {'a','b','c','d’}; >>> >>> __builtin_strcmp(s, "abc") != 0 >>> >>> So, I have

Re: Please review writeup for fixing PR 78809 (inline strcmp for small constant strings)

2017-11-17 Thread Qing Zhao
A would like to be put in gimple fold phase (in routine "gimple_fold_builtin_string_compare" of gimple-fold.c >> OK. Note that various optimizations can expose N or one of the strings >>> to be a constant. So having it as part of the folders makes a lot of >>> sense . >>

Re: Please review writeup for fixing PR 78809 (inline strcmp for small constant strings)

2017-11-17 Thread Qing Zhao
Hi, Jeff, > On Nov 16, 2017, at 7:14 PM, Jeff Law wrote: >> >> In my current local implementation, I used the following routine to get >> the range info: (and use the MINMAXLEN[1]+1 for the length of the >> non-constant string) >> >> /* Determine the minimum and maximum value or string length

Re: Please review writeup for fixing PR 78809 (inline strcmp for small constant strings)

2017-11-17 Thread Qing Zhao
> On Nov 16, 2017, at 6:24 PM, Martin Sebor wrote: >> >> In my current local implementation, I used the following routine to get the >> range info: (and use the MINMAXLEN[1]+1 for the length of the non-constant >> string) >> >> /* Determine the minimum and maximum value or string length that

Re: Please review writeup for fixing PR 78809 (inline strcmp for small constant strings)

2017-11-17 Thread Qing Zhao
> On Nov 16, 2017, at 5:55 PM, Martin Sebor wrote: >> >> A. for strncmp (s1, s2, n) >> if one of "s1" or "s2" is a constant string, "n" is a constant, and >> larger than the length of the constant string: >> change strncmp (s1, s2, n) to strcmp (s1, s2); > > Here and I think in som

Re: Please review writeup for fixing PR 78809 (inline strcmp for small constant strings)

2017-11-16 Thread Jakub Jelinek
On Thu, Nov 16, 2017 at 06:14:35PM -0700, Jeff Law wrote: > > However, this routine currently miss a very obvious case as the following: > > > > char s[100] = {'a','b','c','d’}; > > > > __builtin_strcmp(s, "abc") != 0 > > > > So, I have to change this routine to include such common case.   > >

Re: Please review writeup for fixing PR 78809 (inline strcmp for small constant strings)

2017-11-16 Thread Jeff Law
On 11/16/2017 03:39 PM, Qing Zhao wrote: > Hi, Jeff,  > thanks a lot for your comments. please see my reply in below: > > >> On Nov 16, 2017, at 12:47 PM, Jeff Law > > wrote: >> >>> >>>   B. for strncmp (s1, s2, n) (!)= 0 or strcmp (s1, s2) (!)= 0 >>>      if the result is

Re: Please review writeup for fixing PR 78809 (inline strcmp for small constant strings)

2017-11-16 Thread Martin Sebor
On 11/16/2017 03:39 PM, Qing Zhao wrote: Hi, Jeff, thanks a lot for your comments. please see my reply in below: On Nov 16, 2017, at 12:47 PM, Jeff Law wrote: B. for strncmp (s1, s2, n) (!)= 0 or strcmp (s1, s2) (!)= 0 if the result is ONLY used to do a simple equality test against

Re: Please review writeup for fixing PR 78809 (inline strcmp for small constant strings)

2017-11-16 Thread Martin Sebor
On 11/03/2017 08:59 AM, Qing Zhao wrote: Hi, This is the first time I am asking for a design review for fixing a GCC enhancement request, Let me know if I need to send this email to other mailing list as well. I have been studying PR 78809 for some time https://gcc.gnu.org/bugzilla/show_bug.c

Re: Please review writeup for fixing PR 78809 (inline strcmp for small constant strings)

2017-11-16 Thread Qing Zhao
Hi, Jeff, thanks a lot for your comments. please see my reply in below: > On Nov 16, 2017, at 12:47 PM, Jeff Law wrote: > >> >> B. for strncmp (s1, s2, n) (!)= 0 or strcmp (s1, s2) (!)= 0 >> if the result is ONLY used to do a simple equality test against zero, >> one of "s1" or "s2" i

Re: Please review writeup for fixing PR 78809 (inline strcmp for small constant strings)

2017-11-16 Thread Jeff Law
On 11/03/2017 08:59 AM, Qing Zhao wrote: > Hi, > > This is the first time I am asking for a design review for fixing a GCC > enhancement request, Let me know if I need to send this email to other > mailing list as well. > > I have been studying PR 78809 for some time > https://gcc.gnu.org/bugz

Please review writeup for fixing PR 78809 (inline strcmp for small constant strings)

2017-11-03 Thread Qing Zhao
Hi, This is the first time I am asking for a design review for fixing a GCC enhancement request, Let me know if I need to send this email to other mailing list as well. I have been studying PR 78809 for some time https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78809