common sub-expression elimination

sastry@GODEL.MIEL.MOT.COM (Venkateshwara Sastry)
Fri, 3 Feb 1995 12:14:47 GMT

          From comp.compilers

Related articles
common sub-expression elimination sastry@GODEL.MIEL.MOT.COM (1995-02-03)
Re: common sub-expression elimination danhicks@aol.com (1995-02-05)
Re: common sub-expression elimination preston@tera.com (1995-02-05)
| List of all articles for this month |
Newsgroups: comp.compilers
From: sastry@GODEL.MIEL.MOT.COM (Venkateshwara Sastry)
Keywords: optimize, question, comment
Organization: Compilers Central
Date: Fri, 3 Feb 1995 12:14:47 GMT

Consider the following code with common subexpression


x=a+b+c
y=b+c+a


    With triple or DAG as IR and algorithms discribed in dragon book it is not
possible to identify the RHS of the above two expressions as a common
subexpression.


*Is there any IR (other than post-fix and pre-fix expression) with which
  above transformation can be easily done.




* Are there any papers which deal with efficient way of performing such
optimizations for any kind of IR including post-fix and pre-fix notation.


thanks,
sastry
[It is my impression that in situations like this where you want to take
advantage of associativity, ad hoc approaches work as well as any, e.g. when
building the DAG, make a list of all the things being added together in an
expression, sort the list, and work from there. It also helps collapse
constants, e.g. 1+n+2 => n+3. -John]
--


Post a followup to this message

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