------- Additional Comments From pinskia at gcc dot gnu dot org  2005-01-18 
20:06 -------
(In reply to comment #1)
> A C testcase with the missing jump threading(?):
> 
> void bar(void);
> 
> void foo(const _Bool *flag)
> {
>         if (*flag)
>                 bar();
>         if (*flag)
>                 bar();
> }

No this one cannot be optimizated because we can change what is in flag in 
bar();
For an example in C++  where we can change it:

struct a
{
  int i;
};

a b;

int f(void);

int g(const a &c) 
{
  int i = 0;
  if (c.i)
   i = f();
  if (c.i) // even though c is const&, we can still change it in f()
   i += f();
  return i;
}

int f(void)
{
  b.i=0;
  return 1;
}

extern "C" void abort (void);

int main(void)
{
  b.i = 1;
  if (g(b)!=1)
   abort ();
  return 0;
}

So we cannot do that since it will be an invalid transformation (unless you 
have IPA).

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19507

Reply via email to