Re: Selective Computation...

thp@cs.ucr.edu
17 Jan 2003 20:03:10 -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)
Re: Selective Computation... andreas.gieriet@externsoft.ch (Andreas Gieriet) (2003-01-21)
Re: Selective Computation... liekweg@freenet.de (Florian Liekweg) (2003-01-21)
Re: Selective Computation... marcov@toad.stack.nl (Marco van de Voort) (2003-02-06)
| List of all articles for this month |
From: thp@cs.ucr.edu
Newsgroups: comp.compilers
Date: 17 Jan 2003 20:03:10 -0500
Organization: University of California, Riverside
References: 02-12-116
Keywords: optimize
Posted-Date: 17 Jan 2003 20:03:10 EST

Saru <saru@jeyan.eclipse.co.uk> wrote:
+ 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.


What's wrong with if-then-else, perhaps, in the form:


    X = ( k1 ? p+q : k2 ? p+q' : k3 ? p'+q : assert(0) );


Tom Payne
[On modern architectures, conditional branches can be slow. -John]



Post a followup to this message

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