This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] builtins.c: Fix PR tree-optimization/15743.


On Mon, 2004-05-31 at 11:21, Kazu Hirata wrote:
> Hi,
> 
> Attached is a patch to fix PR tree-optimization/15743.
> 
> Consider:
> 
> char *
> foo (void)
> {
>   const char *s = "abcd";
>   int c = 'p';
>   return index (s, c);
> }
> 
> The last tree-ssa form looks like so:
> 
> foo ()
> {
>   int c;
>   const char * s;
>   char * T.0;
> 
> <bb 0>:
>   T.0_3 = index ("abcd", 112) [tail call];
>   return T.0_3;
> 
> }
> 
> Note that index() is not folded.
> 
> The patch solves this problem by having fold_builtin_1() handle
> index() just like strchr().
> 
> rindex() is handled likewise.
> 
> Tested on i686-pc-linux-gnu.  OK to apply?
> 
> Kazu Hirata
> 
> 2004-05-31  Kazu Hirata  <kazu@cs.umass.edu>
> 
> 	PR tree-optimization/15743.
> 	* builtins.c (fold_builtin_1): Fold index() and rindex().
This is fine.  Please install this patch.  You might also consider
adding your testcase to the testsuite.

jeff



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]