{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/43024","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/43024/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/43024/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/43024/events","html_url":"https://github.com/rust-lang/rust/issues/43024","id":240187664,"number":43024,"title":"`x.trailing_zeros() > n` is not optimized as well as `x & ((1 << n) - 1) == 0` on x86","user":{"login":"oli-obk","id":332036,"avatar_url":"https://avatars1.githubusercontent.com/u/332036?v=3","gravatar_id":"","url":"https://api.github.com/users/oli-obk","html_url":"https://github.com/oli-obk","followers_url":"https://api.github.com/users/oli-obk/followers","following_url":"https://api.github.com/users/oli-obk/following{/other_user}","gists_url":"https://api.github.com/users/oli-obk/gists{/gist_id}","starred_url":"https://api.github.com/users/oli-obk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oli-obk/subscriptions","organizations_url":"https://api.github.com/users/oli-obk/orgs","repos_url":"https://api.github.com/users/oli-obk/repos","events_url":"https://api.github.com/users/oli-obk/events{/privacy}","received_events_url":"https://api.github.com/users/oli-obk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-07-03T14:22:20Z","updated_at":"2017-07-03T14:52:51Z","closed_at":null,"body":"the bitshift and bitand version optimizes to\r\n\r\n```asm\r\n\ttestb\t$15, %dil\r\n\tsete\t%al\r\n\tretq\r\n```\r\n\r\nwhile the `trailing_zeros` version optimizes to\r\n\r\n```asm\r\n\tmovl\t$32, %eax\r\n\ttestl\t%edi, %edi\r\n\tje\t.LBB6_2\r\n\tbsfl\t%edi, %eax\r\n.LBB6_2:\r\n\tcmpl\t$4, %eax\r\n\tseta\t%al\r\n\tretq\r\n```\r\n\r\neven though I find the `trailing_zeros` version much more straight forward\r\n\r\nShould this be reported upstream in llvm or is this something a mir pass should do?"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/312666260","html_url":"https://github.com/rust-lang/rust/issues/43024#issuecomment-312666260","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/43024","id":312666260,"user":{"login":"Mark-Simulacrum","id":5047365,"avatar_url":"https://avatars3.githubusercontent.com/u/5047365?v=3","gravatar_id":"","url":"https://api.github.com/users/Mark-Simulacrum","html_url":"https://github.com/Mark-Simulacrum","followers_url":"https://api.github.com/users/Mark-Simulacrum/followers","following_url":"https://api.github.com/users/Mark-Simulacrum/following{/other_user}","gists_url":"https://api.github.com/users/Mark-Simulacrum/gists{/gist_id}","starred_url":"https://api.github.com/users/Mark-Simulacrum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mark-Simulacrum/subscriptions","organizations_url":"https://api.github.com/users/Mark-Simulacrum/orgs","repos_url":"https://api.github.com/users/Mark-Simulacrum/repos","events_url":"https://api.github.com/users/Mark-Simulacrum/events{/privacy}","received_events_url":"https://api.github.com/users/Mark-Simulacrum/received_events","type":"User","site_admin":false},"created_at":"2017-07-03T14:52:51Z","updated_at":"2017-07-03T14:52:51Z","body":"It looks like trailing_zeros currently calls an LLVM intrinsic (cttz) which has a patch posted against it -- https://reviews.llvm.org/D9284 -- perhaps someone familiar with LLVM (cc @arielb1) could push that through review and then change libcore to not have the conditional that it does today: https://github.com/rust-lang/rust/blob/master/src/libcore/num/mod.rs#L1375-L1390."}}
{"actor":{"display_login":"Mark-Simulacrum"}}