Re: how do I promise const to the optimizer?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux