Re: [PATCH][RFC] Fix PR59860

2014-01-20 Thread Jakub Jelinek
On Mon, Jan 20, 2014 at 11:54:15AM +0100, Richard Biener wrote: > Ok, the following simpler patch also fixes the issue and causes > no testsuite fallout - we restrict the folding in builtins.c to > the case with known src strlen. I've noticed this caused FAIL of strlenopt-4.c which had special reg

Re: [PATCH][RFC] Fix PR59860

2014-01-20 Thread Jakub Jelinek
On Mon, Jan 20, 2014 at 03:53:08PM +0100, Richard Biener wrote: > That works for me. Ok, here is what I've committed after bootstrap/regtest on x86_64-linux and i686-linux. 2014-01-20 Jakub Jelinek PR middle-end/59860 * tree.h (fold_builtin_strcat): New prototype. * bu

Re: [PATCH][RFC] Fix PR59860

2014-01-20 Thread Richard Biener
On Mon, 20 Jan 2014, Jakub Jelinek wrote: > On Mon, Jan 20, 2014 at 02:37:21PM +0100, Richard Biener wrote: > > Well, strcat itself can do that ... but yes, as I said, if you can > > CSE that strlen call then it's a win. But you can't know this without > > It can't, strcat doesn't know the lengt

Re: [PATCH][RFC] Fix PR59860

2014-01-20 Thread Jakub Jelinek
On Mon, Jan 20, 2014 at 02:37:21PM +0100, Richard Biener wrote: > Well, strcat itself can do that ... but yes, as I said, if you can > CSE that strlen call then it's a win. But you can't know this without It can't, strcat doesn't know the length of the src string, we don't have any 3 argument str

Re: [PATCH][RFC] Fix PR59860

2014-01-20 Thread Richard Biener
On Mon, 20 Jan 2014, Jakub Jelinek wrote: > On Mon, Jan 20, 2014 at 01:35:05PM +0100, Richard Biener wrote: > > > tree-ssa-strlen.c apparently both doesn't this case (unknown first strlen, > > > known second strlen or movstr pattern, will only transform that if the > > > length of the resulting st

Re: [PATCH][RFC] Fix PR59860

2014-01-20 Thread Jakub Jelinek
On Mon, Jan 20, 2014 at 01:35:05PM +0100, Richard Biener wrote: > > tree-ssa-strlen.c apparently both doesn't this case (unknown first strlen, > > known second strlen or movstr pattern, will only transform that if the > > length of the resulting string is needed afterwards), and isn't run > > for -

Re: [PATCH][RFC] Fix PR59860

2014-01-20 Thread Richard Biener
On Mon, 20 Jan 2014, Jakub Jelinek wrote: > On Mon, Jan 20, 2014 at 11:54:15AM +0100, Richard Biener wrote: > > Ok, the following simpler patch also fixes the issue and causes > > no testsuite fallout - we restrict the folding in builtins.c to > > the case with known src strlen. > > But then we s

Re: [PATCH][RFC] Fix PR59860

2014-01-20 Thread Jakub Jelinek
On Mon, Jan 20, 2014 at 11:54:15AM +0100, Richard Biener wrote: > Ok, the following simpler patch also fixes the issue and causes > no testsuite fallout - we restrict the folding in builtins.c to > the case with known src strlen. But then we simply never optimize this anymore. Or regress when you

Re: [PATCH][RFC] Fix PR59860

2014-01-20 Thread Richard Biener
On Sun, 19 Jan 2014, Jakub Jelinek wrote: > On Sun, Jan 19, 2014 at 07:05:12PM +0100, Richard Biener wrote: > > The following patch fixes PR59860 by removing the only folding > > builtins.c does that can end up recursing to GIMPLE call stmt > > folding. It does that via strcat -> strlen + strcpy

Re: [PATCH][RFC] Fix PR59860

2014-01-19 Thread Jakub Jelinek
On Sun, Jan 19, 2014 at 07:05:12PM +0100, Richard Biener wrote: > The following patch fixes PR59860 by removing the only folding > builtins.c does that can end up recursing to GIMPLE call stmt > folding. It does that via strcat -> strlen + strcpy folding > and then folding the strlen gimple stmt v