how do I promise const to the optimizer?
Marco Manfredini
mldb@gmx.net
Wed Apr 25 14:56:00 GMT 2007
On Wednesday 25 April 2007 14:14, John (Eljay) Love-Jensen wrote:
> Hi Marco,
>
> Does this work:
>
> int bar(const val *__restrict__ x, const int t)
> {
> const int value = x->tag * t;
> return fun(x, value) + fun(x, value);
> }
>
> Should optimize nicely.
As I wrote in my last paragraph, I can't hand-CSE because the actual code
sequence is generated during inlining, i.e. the actual calls to fun() are
somewhere else and bar doesn't even know about the existence various fun's()
and what they do with x->tag.
What I have is:
inline tak(x) { 3*fun(x,x->tag*7) }
inline tik(x) { 2*fun(x,x->tag*9) }
inline bar(x) { tik(x) + tak(x) }
inline operator +(x,y) { bar(x)+bar(y) }
what I want is:
x+x transformed in { t1=x->tag*7; t2=x->tag*2+t1; t3=fun(x,t1); t4=fun(x,t2);
t5=fun(x,t1); t6=fun(x,t2); 3*(t3+t5)+2*(t4+t6); }
..if x is a pointer or reference.
Marco
More information about the Gcc-help
mailing list