Re: [PATCH] fold more string comparison with known result (PR 90879)

2019-10-04 Thread Jeff Law
On 9/23/19 4:14 PM, Martin Sebor wrote: > > Yes, it looks redundant.  I never remember which of these functions > ICE when their argument is not a constant (e.g., tree_int_cst_lt) > and which ones handle it gracefully (e.g., tree_int_cst_equal) so > I often check even when it isn't necessary.  

Re: [PATCH] fold more string comparison with known result (PR 90879)

2019-09-23 Thread Martin Sebor
On 9/3/19 2:00 PM, Jeff Law wrote: On 8/28/19 3:12 PM, Martin Sebor wrote: On 8/22/19 3:31 PM, Jeff Law wrote: On 8/20/19 8:10 PM, Martin Sebor wrote: Jeff, Please let me know if you agree/disagree and what I need to do to advance this work:   

Re: [PATCH] fold more string comparison with known result (PR 90879)

2019-09-03 Thread Jeff Law
On 8/28/19 3:12 PM, Martin Sebor wrote: > On 8/22/19 3:31 PM, Jeff Law wrote: >> On 8/20/19 8:10 PM, Martin Sebor wrote: >>> Jeff, >>> >>> Please let me know if you agree/disagree and what I need to >>> do to advance this work: >>> >>>    https://gcc.gnu.org/ml/gcc-patches/2019-08/msg00643.html >>

Re: [PATCH] fold more string comparison with known result (PR 90879)

2019-08-28 Thread Martin Sebor
On 8/22/19 3:31 PM, Jeff Law wrote: On 8/20/19 8:10 PM, Martin Sebor wrote: Jeff, Please let me know if you agree/disagree and what I need to do to advance this work:   https://gcc.gnu.org/ml/gcc-patches/2019-08/msg00643.html For the official record, I agree :-) Great! :) Any

Re: [PATCH] fold more string comparison with known result (PR 90879)

2019-08-22 Thread Jeff Law
On 8/20/19 8:10 PM, Martin Sebor wrote: > Jeff, > > Please let me know if you agree/disagree and what I need to > do to advance this work: > >   https://gcc.gnu.org/ml/gcc-patches/2019-08/msg00643.html For the official record, I agree :-) jeff

Re: [PATCH] fold more string comparison with known result (PR 90879)

2019-08-20 Thread Martin Sebor
Jeff, Please let me know if you agree/disagree and what I need to do to advance this work: https://gcc.gnu.org/ml/gcc-patches/2019-08/msg00643.html Thanks Martin On 8/14/19 1:59 PM, Martin Sebor wrote: On 8/13/19 4:46 PM, Jeff Law wrote: On 8/13/19 3:43 PM, Martin Sebor wrote: On 8/13/19

Re: [PATCH] fold more string comparison with known result (PR 90879)

2019-08-14 Thread Martin Sebor
On 8/13/19 4:46 PM, Jeff Law wrote: On 8/13/19 3:43 PM, Martin Sebor wrote: On 8/13/19 2:07 PM, Jeff Law wrote: On 8/9/19 10:51 AM, Martin Sebor wrote: PR tree-optimization/90879 - fold zero-equality of strcmp between a longer string and a smaller array gcc/c-family/ChangeLog: PR

Re: [PATCH] fold more string comparison with known result (PR 90879)

2019-08-14 Thread Martin Sebor
On 8/12/19 7:40 AM, Michael Matz wrote: Hi, On Fri, 9 Aug 2019, Martin Sebor wrote: The solution introduced in C99 is a flexible array. C++ compilers usually support it as well. Those that don't are likely to support the zero-length array (even Visual C++ does). If there's a chance that

Re: [PATCH] fold more string comparison with known result (PR 90879)

2019-08-13 Thread Jeff Law
On 8/13/19 3:43 PM, Martin Sebor wrote: > On 8/13/19 2:07 PM, Jeff Law wrote: >> On 8/9/19 10:51 AM, Martin Sebor wrote: >>> >>> PR tree-optimization/90879 - fold zero-equality of strcmp between a >>> longer string and a smaller array >>> >>> gcc/c-family/ChangeLog: >>> >>> PR

Re: [PATCH] fold more string comparison with known result (PR 90879)

2019-08-13 Thread Martin Sebor
On 8/13/19 2:07 PM, Jeff Law wrote: On 8/9/19 10:51 AM, Martin Sebor wrote: PR tree-optimization/90879 - fold zero-equality of strcmp between a longer string and a smaller array gcc/c-family/ChangeLog: PR tree-optimization/90879 * c.opt (-Wstring-compare): New option.

Re: [PATCH] fold more string comparison with known result (PR 90879)

2019-08-13 Thread Jeff Law
On 8/9/19 10:51 AM, Martin Sebor wrote: > > PR tree-optimization/90879 - fold zero-equality of strcmp between a longer > string and a smaller array > > gcc/c-family/ChangeLog: > > PR tree-optimization/90879 > * c.opt (-Wstring-compare): New option. > > gcc/testsuite/ChangeLog: >

Re: [PATCH] fold more string comparison with known result (PR 90879)

2019-08-12 Thread Jeff Law
On 8/12/19 4:17 PM, Martin Sebor wrote: > On 8/12/19 2:04 PM, Jeff Law wrote: >> On 8/9/19 4:14 PM, Martin Sebor wrote: >>> On 8/9/19 10:58 AM, Jakub Jelinek wrote: On Fri, Aug 09, 2019 at 10:51:09AM -0600, Martin Sebor wrote: > That said, we should change this code one way or the other.

Re: [PATCH] fold more string comparison with known result (PR 90879)

2019-08-12 Thread Martin Sebor
On 8/12/19 2:04 PM, Jeff Law wrote: On 8/9/19 4:14 PM, Martin Sebor wrote: On 8/9/19 10:58 AM, Jakub Jelinek wrote: On Fri, Aug 09, 2019 at 10:51:09AM -0600, Martin Sebor wrote: That said, we should change this code one way or the other. There is even less of a guarantee that other compilers

Re: [PATCH] fold more string comparison with known result (PR 90879)

2019-08-12 Thread Jeff Law
On 8/9/19 10:17 AM, Martin Sebor wrote: > GCC 9 optimizes a subset of expression of the form > (0 == strcmp(a, b)) based on the length and/or size of > the arguments but it doesn't take advantage of all > the opportunities there.  For example in the following, > although it folds the first test to 

Re: [PATCH] fold more string comparison with known result (PR 90879)

2019-08-12 Thread Jeff Law
On 8/9/19 4:14 PM, Martin Sebor wrote: > On 8/9/19 10:58 AM, Jakub Jelinek wrote: >> On Fri, Aug 09, 2019 at 10:51:09AM -0600, Martin Sebor wrote: >>> That said, we should change this code one way or the other. >>> There is even less of a guarantee that other compilers support >>> writing past the

Re: [PATCH] fold more string comparison with known result (PR 90879)

2019-08-12 Thread Michael Matz
Hi, On Fri, 9 Aug 2019, Martin Sebor wrote: > The solution introduced in C99 is a flexible array. C++ > compilers usually support it as well. Those that don't are > likely to support the zero-length array (even Visual C++ does). > If there's a chance that some don't support either do you

Re: [PATCH] fold more string comparison with known result (PR 90879)

2019-08-09 Thread Martin Sebor
On 8/9/19 10:58 AM, Jakub Jelinek wrote: On Fri, Aug 09, 2019 at 10:51:09AM -0600, Martin Sebor wrote: That said, we should change this code one way or the other. There is even less of a guarantee that other compilers support writing past the end of arrays that have non-zero size than that they

Re: [PATCH] fold more string comparison with known result (PR 90879)

2019-08-09 Thread Jakub Jelinek
On Fri, Aug 09, 2019 at 10:51:09AM -0600, Martin Sebor wrote: > That said, we should change this code one way or the other. > There is even less of a guarantee that other compilers support > writing past the end of arrays that have non-zero size than > that they recognize the documented

Re: [PATCH] fold more string comparison with known result (PR 90879)

2019-08-09 Thread Martin Sebor
On 8/9/19 10:22 AM, Jakub Jelinek wrote: On Fri, Aug 09, 2019 at 10:17:12AM -0600, Martin Sebor wrote: --- a/gcc/gengtype-state.c +++ b/gcc/gengtype-state.c @@ -79,6 +79,14 @@ enum state_token_en STOK_NAME /* hash-consed name or identifier. */ }; +/* Suppress

Re: [PATCH] fold more string comparison with known result (PR 90879)

2019-08-09 Thread Jakub Jelinek
On Fri, Aug 09, 2019 at 10:17:12AM -0600, Martin Sebor wrote: > --- a/gcc/gengtype-state.c > +++ b/gcc/gengtype-state.c > @@ -79,6 +79,14 @@ enum state_token_en >STOK_NAME /* hash-consed name or identifier. */ > }; > > +/* Suppress warning: ISO C forbids zero-size array

[PATCH] fold more string comparison with known result (PR 90879)

2019-08-09 Thread Martin Sebor
GCC 9 optimizes a subset of expression of the form (0 == strcmp(a, b)) based on the length and/or size of the arguments but it doesn't take advantage of all the opportunities there. For example in the following, although it folds the first test to false it doesn't fold the second one: char