{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/21627","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/21627/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/21627/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/21627/events","html_url":"https://github.com/rust-lang/rust/issues/21627","id":55426452,"number":21627,"title":"Incorrect sign extension from `i32` to `i64` on AArch64","user":{"login":"akiss77","id":9976482,"avatar_url":"https://avatars.githubusercontent.com/u/9976482?v=3","gravatar_id":"","url":"https://api.github.com/users/akiss77","html_url":"https://github.com/akiss77","followers_url":"https://api.github.com/users/akiss77/followers","following_url":"https://api.github.com/users/akiss77/following{/other_user}","gists_url":"https://api.github.com/users/akiss77/gists{/gist_id}","starred_url":"https://api.github.com/users/akiss77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akiss77/subscriptions","organizations_url":"https://api.github.com/users/akiss77/orgs","repos_url":"https://api.github.com/users/akiss77/repos","events_url":"https://api.github.com/users/akiss77/events{/privacy}","received_events_url":"https://api.github.com/users/akiss77/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-25T19:36:32Z","updated_at":"2015-01-26T00:57:17Z","closed_at":null,"body":"When compiling the following code (which is a minimized version of `impl_to_primitive_int_to_int!` from libcore/num/mod.rs) on AArch64 with rustc from 2015-01-24, the output is unfortunately `NO :(`\r\n\r\n```\r\nuse std::num::Int;\r\n\r\nfn main() {\r\n\tlet n = 960 as i64;\r\n\tlet min_value: i32 = Int::min_value();\r\n\tif min_value as i64 <= n {\r\n\t\tprintln!(\"OK :)\");\r\n\t} else {\r\n\t\tprintln!(\"NO :(\")\r\n\t}\r\n}\r\n```\r\n\r\nThe disassembled code of `main` starts as:\r\n```\r\n00000000000071ec <_ZN4main20h2d56baed33734ff2faaE>:\r\n    71ec:       a9be6ffc        stp     x28, x27, [sp,#-32]!\r\n    71f0:       a9017bfd        stp     x29, x30, [sp,#16]\r\n    71f4:       910043fd        add     x29, sp, #0x10\r\n    71f8:       d10443ff        sub     sp, sp, #0x110\r\n    71fc:       b27a0fe8        orr     x8, xzr, #0x3c0\r\n    7200:       f81e83a8        str     x8, [x29,#-24]\r\n    7204:       94000048        bl      7324 <_ZN3num7i32.Int9min_value20hb9150aaae7f1b75agpbE>\r\n    7208:       b81e43a0        str     w0, [x29,#-28]\r\n    720c:       b89e43a8        ldrsw   x8, [x29,#-28]\r\n    7210:       2a0803e0        mov     w0, w8\r\n    7214:       2a0003e8        mov     w8, w0\r\n    7218:       f85e83a9        ldr     x9, [x29,#-24]\r\n    721c:       eb09011f        cmp     x8, x9\r\n```\r\n\r\nThe problem is with the two moves at `0x7210` and `0x7214`, which erroneously clear the top 32 bits of `x8`, which thus becomes `0x80000000` instead of the expected `0xffffffff80000000`.\r\n\r\nThe error was first found in the rustup_20150109 branch of Servo (https://github.com/servo/servo/pull/4716), but the latest Rust also exhibits the problem (as shown above)."},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/71403277","html_url":"https://github.com/rust-lang/rust/issues/21627#issuecomment-71403277","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/21627","id":71403277,"user":{"login":"akiss77","id":9976482,"avatar_url":"https://avatars.githubusercontent.com/u/9976482?v=3","gravatar_id":"","url":"https://api.github.com/users/akiss77","html_url":"https://github.com/akiss77","followers_url":"https://api.github.com/users/akiss77/followers","following_url":"https://api.github.com/users/akiss77/following{/other_user}","gists_url":"https://api.github.com/users/akiss77/gists{/gist_id}","starred_url":"https://api.github.com/users/akiss77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akiss77/subscriptions","organizations_url":"https://api.github.com/users/akiss77/orgs","repos_url":"https://api.github.com/users/akiss77/repos","events_url":"https://api.github.com/users/akiss77/events{/privacy}","received_events_url":"https://api.github.com/users/akiss77/received_events","type":"User","site_admin":false},"created_at":"2015-01-26T00:57:17Z","updated_at":"2015-01-26T00:57:17Z","body":"Just had a chat on #llvm and got a lot of help from Tim Northover. He found out that the bug has already been discovered and fixed in LLVM: https://github.com/llvm-mirror/llvm/commit/ca07e256f62f772d14c42f41af46f2aeacc54983\r\n\r\nHow/would it be possible to adapt that fix to the LLVM used by rust?"}}