{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/32031","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/32031/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/32031/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/32031/events","html_url":"https://github.com/rust-lang/rust/issues/32031","id":138317776,"number":32031,"title":"Sub-optimal codegen for float newtypes","user":{"login":"bsteinb","id":3883096,"avatar_url":"https://avatars.githubusercontent.com/u/3883096?v=3","gravatar_id":"","url":"https://api.github.com/users/bsteinb","html_url":"https://github.com/bsteinb","followers_url":"https://api.github.com/users/bsteinb/followers","following_url":"https://api.github.com/users/bsteinb/following{/other_user}","gists_url":"https://api.github.com/users/bsteinb/gists{/gist_id}","starred_url":"https://api.github.com/users/bsteinb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bsteinb/subscriptions","organizations_url":"https://api.github.com/users/bsteinb/orgs","repos_url":"https://api.github.com/users/bsteinb/repos","events_url":"https://api.github.com/users/bsteinb/events{/privacy}","received_events_url":"https://api.github.com/users/bsteinb/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rust/labels/A-codegen","name":"A-codegen","color":"d7e102"}],"state":"open","locked":false,"assignee":{"login":"eddyb","id":77424,"avatar_url":"https://avatars.githubusercontent.com/u/77424?v=3","gravatar_id":"","url":"https://api.github.com/users/eddyb","html_url":"https://github.com/eddyb","followers_url":"https://api.github.com/users/eddyb/followers","following_url":"https://api.github.com/users/eddyb/following{/other_user}","gists_url":"https://api.github.com/users/eddyb/gists{/gist_id}","starred_url":"https://api.github.com/users/eddyb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eddyb/subscriptions","organizations_url":"https://api.github.com/users/eddyb/orgs","repos_url":"https://api.github.com/users/eddyb/repos","events_url":"https://api.github.com/users/eddyb/events{/privacy}","received_events_url":"https://api.github.com/users/eddyb/received_events","type":"User","site_admin":false},"milestone":null,"comments":4,"created_at":"2016-03-03T22:35:54Z","updated_at":"2016-04-09T07:33:59Z","closed_at":null,"body":"It seems that floating point types wrapped in newtypes are passed to functions in general purpose registers instead of SIMD registers the way plain f32 and f64 are. Consider this [code example in playpen](http://is.gd/5oW5Nn).\r\n\r\nWithout inlining, `add_f32()` and `add_f64()` compile to a single instruction (plus return) while `add_newtype_{f32|f64}()` first have to move their arguments from a general purpose register perform the addition and move the result back to the GPR.\r\n\r\nWith inlining, the situation is better, but still not optimal. Once again, the functions defined on plain types work directly in SIMD registers and the loop now gets unrolled by a factor of 10. For the newtypes, the accumulator is still kept in a GPR, however the loop is unrolled by a factor of 5. Here, the accumulator is only moved from the GPR to a SIMD register at the start of a loop iteration and moved back at the end (after 5 additions have been performed)."},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/207734049","html_url":"https://github.com/rust-lang/rust/issues/32031#issuecomment-207734049","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/32031","id":207734049,"user":{"login":"bsteinb","id":3883096,"avatar_url":"https://avatars.githubusercontent.com/u/3883096?v=3","gravatar_id":"","url":"https://api.github.com/users/bsteinb","html_url":"https://github.com/bsteinb","followers_url":"https://api.github.com/users/bsteinb/followers","following_url":"https://api.github.com/users/bsteinb/following{/other_user}","gists_url":"https://api.github.com/users/bsteinb/gists{/gist_id}","starred_url":"https://api.github.com/users/bsteinb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bsteinb/subscriptions","organizations_url":"https://api.github.com/users/bsteinb/orgs","repos_url":"https://api.github.com/users/bsteinb/repos","events_url":"https://api.github.com/users/bsteinb/events{/privacy}","received_events_url":"https://api.github.com/users/bsteinb/received_events","type":"User","site_admin":false},"created_at":"2016-04-09T07:33:59Z","updated_at":"2016-04-09T07:33:59Z","body":"Hey, the situation here seems to have improved recently. The nightly compiler on playpen now produces the same code for bare `f32`/`f64` and their newtype wrapped counterparts."}}