Selective Computation...

Saru <saru@jeyan.eclipse.co.uk>
26 Dec 2002 23:40:39 -0500

          From comp.compilers

Related articles
Selective Computation... saru@jeyan.eclipse.co.uk (Saru) (2002-12-26)
Re: Selective Computation... jeyan@jeyan.eclipse.co.uk (Saru) (2002-12-30)
Re: Selective Computation... saru@jeyan.eclipse.co.uk (Saru) (2002-12-30)
Re: Selective Computation... joachim_d@gmx.de (Joachim Durchholz) (2002-12-31)
Re: Selective Computation... thp@cs.ucr.edu (2003-01-17)
Re: Selective Computation... Patrick.Volteau@st.com (Patrick Volteau) (2003-01-20)
Re: Selective Computation... strohm@airmail.net (John R. Strohm) (2003-01-21)
[3 later articles]
| List of all articles for this month |
From: Saru <saru@jeyan.eclipse.co.uk>
Newsgroups: comp.compilers
Date: 26 Dec 2002 23:40:39 -0500
Organization: Ye 'Ol Disorganized NNTPCache groupie
Keywords: code, optimize, question
Posted-Date: 26 Dec 2002 23:40:39 EST

I have a computation which evaluates X as


X=k1*(p+q)+k2*(p+q')+k3*(p'+q);


where k1, k2, k3, p, q , p', and q' are variables (not constants).
Though "p", "q", "p'" and "q'" can take any arbitrary value,
k1, k2 and k3 can take either 0 or 1. Again, within k1, k2 and k3 only
one of them can be 1 at any given time. I am wondering there exists any
method to speedup/optimize this computation (in a way that could be done
on all architectures/processors). This computation appears inside a
loop and clearly I don't want to use any if-then-else.


Any help would be appreciated greatly.


Thanks in advance.


    Saru
[If you can combine k1, k2, and k3 into a three bit mask that can
take on the values 0 to 7, you could use a switch that would compile
into an indirect jump that is usually rather fast. If you really want
to speed things up and k1,k2,k3 don't change in the loop, write three
versions of the loop and at runtime pick the appropriate one to use. -John]





Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.