{"action":"created","issue":{"url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/3938","labels_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/3938/labels{/name}","comments_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/3938/comments","events_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/3938/events","html_url":"https://github.com/HaxeFoundation/haxe/issues/3938","id":59389301,"number":3938,"title":"[analyzer] Prune assignments in dead branches","user":{"login":"Simn","id":634365,"avatar_url":"https://avatars.githubusercontent.com/u/634365?v=3","gravatar_id":"","url":"https://api.github.com/users/Simn","html_url":"https://github.com/Simn","followers_url":"https://api.github.com/users/Simn/followers","following_url":"https://api.github.com/users/Simn/following{/other_user}","gists_url":"https://api.github.com/users/Simn/gists{/gist_id}","starred_url":"https://api.github.com/users/Simn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Simn/subscriptions","organizations_url":"https://api.github.com/users/Simn/orgs","repos_url":"https://api.github.com/users/Simn/repos","events_url":"https://api.github.com/users/Simn/events{/privacy}","received_events_url":"https://api.github.com/users/Simn/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/HaxeFoundation/haxe/labels/feature-analyzer","name":"feature-analyzer","color":"207de5"}],"state":"open","locked":false,"assignee":{"login":"Simn","id":634365,"avatar_url":"https://avatars.githubusercontent.com/u/634365?v=3","gravatar_id":"","url":"https://api.github.com/users/Simn","html_url":"https://github.com/Simn","followers_url":"https://api.github.com/users/Simn/followers","following_url":"https://api.github.com/users/Simn/following{/other_user}","gists_url":"https://api.github.com/users/Simn/gists{/gist_id}","starred_url":"https://api.github.com/users/Simn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Simn/subscriptions","organizations_url":"https://api.github.com/users/Simn/orgs","repos_url":"https://api.github.com/users/Simn/repos","events_url":"https://api.github.com/users/Simn/events{/privacy}","received_events_url":"https://api.github.com/users/Simn/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/HaxeFoundation/haxe/milestones/5","html_url":"https://github.com/HaxeFoundation/haxe/milestones/3.3","labels_url":"https://api.github.com/repos/HaxeFoundation/haxe/milestones/5/labels","id":586975,"number":5,"title":"3.3","description":"","creator":{"login":"ncannasse","id":1022912,"avatar_url":"https://avatars.githubusercontent.com/u/1022912?v=3","gravatar_id":"","url":"https://api.github.com/users/ncannasse","html_url":"https://github.com/ncannasse","followers_url":"https://api.github.com/users/ncannasse/followers","following_url":"https://api.github.com/users/ncannasse/following{/other_user}","gists_url":"https://api.github.com/users/ncannasse/gists{/gist_id}","starred_url":"https://api.github.com/users/ncannasse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ncannasse/subscriptions","organizations_url":"https://api.github.com/users/ncannasse/orgs","repos_url":"https://api.github.com/users/ncannasse/repos","events_url":"https://api.github.com/users/ncannasse/events{/privacy}","received_events_url":"https://api.github.com/users/ncannasse/received_events","type":"User","site_admin":false},"open_issues":225,"closed_issues":66,"state":"open","created_at":"2014-03-04T14:22:27Z","updated_at":"2015-06-03T14:43:28Z","due_on":"2015-09-14T22:00:00Z","closed_at":null},"comments":6,"created_at":"2015-03-01T09:18:17Z","updated_at":"2015-06-04T10:58:49Z","closed_at":null,"body":"The following code is not completely optimized at the moment:\r\n\r\n```\r\nclass Main {\r\n\tstatic function main() {\r\n\t\tvar a = 1;\r\n\t\tif (a == 1) {\r\n\t\t\ta = 2;\r\n\t\t} else {\r\n\t\t\ta = 3;\r\n\t\t}\r\n\t\ttrace(a);\r\n\t}\r\n}\r\n```\r\n\r\nJS output:\r\n\r\n```\r\n\tvar a = 1;\r\n\ta = 2;\r\n\tconsole.log(a);\r\n```\r\n\r\nClearly this could be optimized to `console.log(2)` here. The problem is that while we cut off dead branches during const-propagation, we do not prune the assignments that occur there. Thus the value of `a` after the branch is still `__ssa__phi(2, 3)` and const propagation doesn't happen.\r\n\r\nThis isn't hard to fix but is going to require some internal changes, so I'll leave it for 3.3."},"comment":{"url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/comments/108840235","html_url":"https://github.com/HaxeFoundation/haxe/issues/3938#issuecomment-108840235","issue_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/3938","id":108840235,"user":{"login":"delahee","id":644444,"avatar_url":"https://avatars.githubusercontent.com/u/644444?v=3","gravatar_id":"","url":"https://api.github.com/users/delahee","html_url":"https://github.com/delahee","followers_url":"https://api.github.com/users/delahee/followers","following_url":"https://api.github.com/users/delahee/following{/other_user}","gists_url":"https://api.github.com/users/delahee/gists{/gist_id}","starred_url":"https://api.github.com/users/delahee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/delahee/subscriptions","organizations_url":"https://api.github.com/users/delahee/orgs","repos_url":"https://api.github.com/users/delahee/repos","events_url":"https://api.github.com/users/delahee/events{/privacy}","received_events_url":"https://api.github.com/users/delahee/received_events","type":"User","site_admin":false},"created_at":"2015-06-04T10:58:49Z","updated_at":"2015-06-04T10:58:49Z","body":"Ok thank you !\n\n2015-06-04 12:56 GMT+02:00 Simon Krajewski <notifications@github.com>:\n\n> Try @:analyzer(no_const_propagation)\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/HaxeFoundation/haxe/issues/3938#issuecomment-108839754>\n> .\n>\n\n\n\n-- \nDavid Elahee\n"}}