coverband / spitfire

Automatically exported from code.google.com/p/spitfire
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Loop invariant hoisting optimization generates broken code #5

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Source:

#for $x in $foobar
    #set $broken_variable = 'test'
    $broken_variable
#end for

With -O4, this compiles to:

    _fphB50896DF = _self_filter_function(broken_variable) # << use before 
definition
    for x in _rph_foobar:
      broken_variable = u'test'

The stop-gap fix is (checked in r115) is to not hoist any variables that have 
other dependencies in the loop. A warning is emitted instead. Long term 
fix should be to hoist both the loop invariant variable and all invariant 
dependencies.

Original issue reported on code.google.com by shalabh....@gmail.com on 25 Jan 2010 at 11:13