{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/17880","repository_url":"https://api.github.com/repos/JuliaLang/julia","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/17880/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/17880/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/17880/events","html_url":"https://github.com/JuliaLang/julia/issues/17880","id":169813267,"number":17880,"title":"Dead branch elimination after inlining","user":{"login":"TotalVerb","id":12903942,"avatar_url":"https://avatars.githubusercontent.com/u/12903942?v=3","gravatar_id":"","url":"https://api.github.com/users/TotalVerb","html_url":"https://github.com/TotalVerb","followers_url":"https://api.github.com/users/TotalVerb/followers","following_url":"https://api.github.com/users/TotalVerb/following{/other_user}","gists_url":"https://api.github.com/users/TotalVerb/gists{/gist_id}","starred_url":"https://api.github.com/users/TotalVerb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TotalVerb/subscriptions","organizations_url":"https://api.github.com/users/TotalVerb/orgs","repos_url":"https://api.github.com/users/TotalVerb/repos","events_url":"https://api.github.com/users/TotalVerb/events{/privacy}","received_events_url":"https://api.github.com/users/TotalVerb/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-08-07T19:59:20Z","updated_at":"2016-08-08T02:08:53Z","closed_at":null,"body":"In the below min-repro, julia successfully inlines `g(x)`;\r\n\r\n```julia\r\ng(x) = true\r\nf(x) = g(x) ? 1 : 1.0\r\n```\r\n\r\nNevertheless, inference does not eliminate the dead branch, and so the result is boxed:\r\n\r\n```julia\r\njulia> @code_warntype f(1)\r\nVariables:\r\n  #self#::#f\r\n  x::Int64\r\n\r\nBody:\r\n  begin \r\n      unless $(QuoteNode(true)) goto 3\r\n      return 1\r\n      3: \r\n      return 1.0\r\n  end::Union{Float64,Int64}\r\n```\r\n\r\nAlthough LLVM successfully removes the branch, it is too late to unbox the return value.\r\n\r\nWould it be feasible to run dead branch elimination after inlining?\r\n\r\n(Related to this SO question: http://stackoverflow.com/questions/38811881/possible-to-constant-propagate-if-statement-without-dispatch)"},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/238126732","html_url":"https://github.com/JuliaLang/julia/issues/17880#issuecomment-238126732","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/17880","id":238126732,"user":{"login":"yuyichao","id":712232,"avatar_url":"https://avatars.githubusercontent.com/u/712232?v=3","gravatar_id":"","url":"https://api.github.com/users/yuyichao","html_url":"https://github.com/yuyichao","followers_url":"https://api.github.com/users/yuyichao/followers","following_url":"https://api.github.com/users/yuyichao/following{/other_user}","gists_url":"https://api.github.com/users/yuyichao/gists{/gist_id}","starred_url":"https://api.github.com/users/yuyichao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuyichao/subscriptions","organizations_url":"https://api.github.com/users/yuyichao/orgs","repos_url":"https://api.github.com/users/yuyichao/repos","events_url":"https://api.github.com/users/yuyichao/events{/privacy}","received_events_url":"https://api.github.com/users/yuyichao/received_events","type":"User","site_admin":false},"created_at":"2016-08-08T02:08:53Z","updated_at":"2016-08-08T02:08:53Z","body":"Would it help to stop widening `Const`s before inferring methods?"}}
{"actor":{"display_login":"yuyichao"}}