{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/coreclr/issues/3385","repository_url":"https://api.github.com/repos/dotnet/coreclr","labels_url":"https://api.github.com/repos/dotnet/coreclr/issues/3385/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/coreclr/issues/3385/comments","events_url":"https://api.github.com/repos/dotnet/coreclr/issues/3385/events","html_url":"https://github.com/dotnet/coreclr/pull/3385","id":136799418,"number":3385,"title":"ARM64: Fix for Mod 1","user":{"login":"kyulee1","id":10963908,"avatar_url":"https://avatars.githubusercontent.com/u/10963908?v=3","gravatar_id":"","url":"https://api.github.com/users/kyulee1","html_url":"https://github.com/kyulee1","followers_url":"https://api.github.com/users/kyulee1/followers","following_url":"https://api.github.com/users/kyulee1/following{/other_user}","gists_url":"https://api.github.com/users/kyulee1/gists{/gist_id}","starred_url":"https://api.github.com/users/kyulee1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kyulee1/subscriptions","organizations_url":"https://api.github.com/users/kyulee1/orgs","repos_url":"https://api.github.com/users/kyulee1/repos","events_url":"https://api.github.com/users/kyulee1/events{/privacy}","received_events_url":"https://api.github.com/users/kyulee1/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/coreclr/labels/2%20-%20In%20Progress","name":"2 - In Progress","color":"CCCCCC"},{"url":"https://api.github.com/repos/dotnet/coreclr/labels/cla-already-signed","name":"cla-already-signed","color":"009800"},{"url":"https://api.github.com/repos/dotnet/coreclr/labels/CodeGen","name":"CodeGen","color":"d4c5f9"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-02-26T20:01:50Z","updated_at":"2016-03-01T00:31:04Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/dotnet/coreclr/pulls/3385","html_url":"https://github.com/dotnet/coreclr/pull/3385","diff_url":"https://github.com/dotnet/coreclr/pull/3385.diff","patch_url":"https://github.com/dotnet/coreclr/pull/3385.patch"},"body":"In Arm64, mod a % b is simulated as a - a / b * b.\r\nWhen b (divisor) is 1, the result is simply 0.\r\nThis optimization is done in the post-pass of morph\r\nwhile JIT already expands the mod operation in the pre-pass of morph.\r\nThis unnessary expansion results in bad codegen down the road.\r\nSo, the fix is to move this special case handling in the pre-pass.\r\n\r\nBefore\r\n```\r\n[000035] -------------                   /--*  lclVar    int    V02 tmp1\r\n[000036] -A-----------                /--*  comma     int\r\n[000001] -------------                |  |  /--*  const     int 0xffffffff80000000\r\n[000034] -A-----------                |  \\--*  =         int\r\n[000033] D------N-----                |     \\--*  lclVar    int    V02 tmp1\r\n[000041] -A-----------             /--*  -         int\r\n[000040] -------------             |  \\--*  lclVar    int    V02\r\n[000006] -A-----------             *  =         int\r\n[000005] D------N-----             \\--*  lclVar    int    V01 tmp0\r\n```\r\n\r\nAfter\r\n```\r\n[000033] -------------             /--*  const     int    0\r\n[000006] -A-----------             *  =         int\r\n[000005] D------N-----             \\--*  lclVar    int    V01 tmp0\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/dotnet/coreclr/issues/comments/190468252","html_url":"https://github.com/dotnet/coreclr/pull/3385#issuecomment-190468252","issue_url":"https://api.github.com/repos/dotnet/coreclr/issues/3385","id":190468252,"user":{"login":"CarolEidt","id":2973870,"avatar_url":"https://avatars.githubusercontent.com/u/2973870?v=3","gravatar_id":"","url":"https://api.github.com/users/CarolEidt","html_url":"https://github.com/CarolEidt","followers_url":"https://api.github.com/users/CarolEidt/followers","following_url":"https://api.github.com/users/CarolEidt/following{/other_user}","gists_url":"https://api.github.com/users/CarolEidt/gists{/gist_id}","starred_url":"https://api.github.com/users/CarolEidt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CarolEidt/subscriptions","organizations_url":"https://api.github.com/users/CarolEidt/orgs","repos_url":"https://api.github.com/users/CarolEidt/repos","events_url":"https://api.github.com/users/CarolEidt/events{/privacy}","received_events_url":"https://api.github.com/users/CarolEidt/received_events","type":"User","site_admin":false},"created_at":"2016-03-01T00:31:04Z","updated_at":"2016-03-01T00:31:04Z","body":"LGTM aside from possibly adding back the call to DEBUG_DESTROY_NODE"}}