{"issue":{"milestone":null,"title":"[FRG-25] Case statement too eagerly optimizes common sub-expressions","created_at":"2011-12-30T03:52:23Z","user":{"login":"dynamobi-build","id":1123017,"url":"https://api.github.com/users/dynamobi-build","avatar_url":"https://secure.gravatar.com/avatar/cb215b3d786be20761071a562a56af64?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"cb215b3d786be20761071a562a56af64"},"labels":[{"name":"Fennel Calc Codegen","url":"https://api.github.com/repos/dynamobi/dynamobi/labels/Fennel+Calc+Codegen","color":"14bb92"},{"name":"FRG","url":"https://api.github.com/repos/dynamobi/dynamobi/labels/FRG","color":"1f8f0d"}],"updated_at":"2011-12-30T03:52:26Z","state":"open","id":2686409,"closed_at":null,"html_url":"https://github.com/dynamobi/dynamobi/issues/845","pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"body":"<b><i>[reporter=\"jpham\", created=\"Mon, 23 Jan 2006 15:25:27 -0500 (GMT-05:00)\"]</i></b>\nWhen it is translating a program, the translator avoids translating the<br/>\nsame expression twice. (via implementNode()) For example, if you do:<br/>\n<br/>\n  values 5*10, 5*10;<br/>\n<br/>\nIt only codes 5*10 once. This is usually the right thing. However, it<br/>\nhas implications for conditional code. Consider the expression:<br/>\n<br/>\n  if ($0) {<br/>\n    5*10;<br/>\n  } else {<br/>\n    5*10+2;<br/>\n  }<br/>\n<br/>\nThe common sub-expression would undefined for the \"else\" clause. In Rex,<br/>\nthis is represented as:<br/>\n<br/>\n  Case($0, 5*10, 5*10+2)<br/>\n<br/>\nThis gets translated to roughly the following Fennel calculator code:<br/>\n<br/>\n0:  if not $0 jump 4<br/>\n1:    L0 = 5*10<br/>\n2:    L1 = L0<br/>\n3:    jump 5<br/>\n4:  L1 = L0 + 2<br/>\n5:  return L1<br/>\n<br/>\nI am putting in some code to scope the conditional value expressions. <br/>\nIt would be good to have someone double check it and make <br/>\nsure it was ok.","number":845,"url":"https://api.github.com/repos/dynamobi/dynamobi/issues/845","comments":2,"assignee":null},"action":"opened"}