This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/19507] missed tree-optimization
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Jan 2005 20:06:05 -0000
- Subject: [Bug tree-optimization/19507] missed tree-optimization
- References: <20050118161903.19507.rguenth@tat.physik.uni-tuebingen.de>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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