This is the mail archive of the gcc-help@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]

optimizing costly calculation


hi,

I have a piece of code which does roughly this (after inlining):

Foo *foo1 = bar (ctx);
foo1->something ();
Foo *foo2 = bar (ctx);
foo2->something ();

bar is a function which will always return the same value if its input
is the same value (and ctx is constant over the function body) so, I
would like to instruct gcc that he can optimize away the second call
to bar but I could not find any obvious way to do this. Is this a
really stupid idea or did I miss something obvious ?

Mathieu
-- 
Mathieu Lacage <mathieu.lacage@gmail.com>


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