public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* [tree-ssa-branch] Optimizing non-SIMPLE trees
@ 2002-08-09  7:09 Diego Novillo
  2002-08-09 11:30 ` Daniel Berlin
  2002-08-09 15:57 ` Richard Henderson
  0 siblings, 2 replies; 17+ messages in thread
From: Diego Novillo @ 2002-08-09  7:09 UTC (permalink / raw)
  To: gcc

I ran into this problem with constant propagation and builtins.
In string-opt-8.c we have something like this:

  const char *const s1 = "hello world";
  const char *s2;
  s2 = s1;
  if (strncmp (++s2, "", 1) <= 0)
    abort ();

The simplifier refuses to simplify the call to strncmp() because
it contains at least one constant argument.  It does this to
avoid tricking the code generator into not outputting a builtin
call when all the arguments are constant.

Clearly, the simplifier could be a bit smarter in this case, but
the point remains that we will many times refuse to simplify a
builtin or other special trees.  The question is now, how do we
tell the optimizers to keep their hands off these trees?  In this
case, constant propagation is generating this:

  s2 = (const char * const)(char *)"hello world";
  T.1 = strncmp ( ++(const char * const)(char *)"hello world", (const char *)(char *)"", 1);
  if (T.1 <= 0)
    {
      abort (); 
    }

Oops.  CCP didn't realize that ++s2 had side-effects.  It didn't
have to, of course.  All the data flow information was correct,
s2 is first used and then defined in that expression, so the
reaching definition from the previous assignment could be
replaced in that expression.  However, the expression wasn't in
SIMPLE form.

An easy way out in this case would be for CCP to ask each
expression whether it's in SIMPLE form or not.  This is a problem
because the SIMPLE grammar is not context free w.r.t. expressions
(a valid RHS cannot be used as a predicate inside an if() node,
for instance).

One idea is for the simplifier to flag these trees and make them
clobber all the symbols that they reference.  I'm not quite sure
how this would affect other optimizers, though.


Diego.

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2002-08-23 10:41 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-09  7:09 [tree-ssa-branch] Optimizing non-SIMPLE trees Diego Novillo
2002-08-09 11:30 ` Daniel Berlin
2002-08-10 17:57   ` Diego Novillo
2002-08-09 15:57 ` Richard Henderson
2002-08-09 23:15   ` Diego Novillo
2002-08-10 14:31     ` Richard Henderson
2002-08-10 15:05       ` Diego Novillo
2002-08-10 15:12         ` Jan Hubicka
2002-08-10 16:02           ` Diego Novillo
2002-08-10 22:17             ` Richard Henderson
2002-08-11  2:06             ` Jan Hubicka
2002-08-11 10:23               ` Richard Henderson
2002-08-11 10:36                 ` Jan Hubicka
2002-08-23  3:24                 ` Jason Merrill
2002-08-23  3:32                   ` Jan Hubicka
2002-08-23 10:33                   ` Richard Henderson
2002-08-23 10:41                     ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).