{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/10362","labels_url":"https://api.github.com/repos/golang/go/issues/10362/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/10362/comments","events_url":"https://api.github.com/repos/golang/go/issues/10362/events","html_url":"https://github.com/golang/go/issues/10362","id":66884431,"number":10362,"title":"cmd/{5,6,7,8,9g}: assigning large values does not use memmove","user":{"login":"davecheney","id":7171,"avatar_url":"https://avatars.githubusercontent.com/u/7171?v=3","gravatar_id":"","url":"https://api.github.com/users/davecheney","html_url":"https://github.com/davecheney","followers_url":"https://api.github.com/users/davecheney/followers","following_url":"https://api.github.com/users/davecheney/following{/other_user}","gists_url":"https://api.github.com/users/davecheney/gists{/gist_id}","starred_url":"https://api.github.com/users/davecheney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davecheney/subscriptions","organizations_url":"https://api.github.com/users/davecheney/orgs","repos_url":"https://api.github.com/users/davecheney/repos","events_url":"https://api.github.com/users/davecheney/events{/privacy}","received_events_url":"https://api.github.com/users/davecheney/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-07T13:29:54Z","updated_at":"2015-04-07T13:37:40Z","closed_at":null,"body":"Consider this piece of code\r\n```\r\npackage main\r\n\r\nimport \"fmt\"\r\n\r\nfunc main() {\r\n        f()\r\n}\r\n\r\nfunc f() {\r\n        var a [200]int\r\n        var b [200]int\r\n\r\n        a = b\r\n        b = a\r\n\r\n        fmt.Println(&a, &b)\r\n}\r\n```\r\n\r\nThe assignments of `a = b` or `b = a` where the size of `a` or `b` is above the DUFFCOPY limit of 128 words produces some very simplistic code\r\n```\r\n        a = b\r\n   10c60:       e1a01004        mov     r1, r4\r\n   10c64:       e1a00005        mov     r0, r5\r\n   10c68:       e2843e32        add     r3, r4, #800    ; 0x320\r\n   10c6c:       e4912004        ldr     r2, [r1], #4\r\n   10c70:       e4802004        str     r2, [r0], #4\r\n   10c74:       e1530001        cmp     r3, r1\r\n   10c78:       1afffffb        bne     10c6c <main.f+0x4c>\r\n        b = a\r\n   10c7c:       e1a01005        mov     r1, r5\r\n   10c80:       e1a00004        mov     r0, r4\r\n   10c84:       e2853e32        add     r3, r5, #800    ; 0x320\r\n   10c88:       e4912004        ldr     r2, [r1], #4\r\n   10c8c:       e4802004        str     r2, [r0], #4\r\n   10c90:       e1530001        cmp     r3, r1\r\n   10c94:       1afffffb        bne     10c88 <main.f+0x68>\r\n```\r\nShould `sgen/stackcopy` take the opportunity to setup a call to `runtime.memmove` for values larger than 128 words ?"},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/90556600","html_url":"https://github.com/golang/go/issues/10362#issuecomment-90556600","issue_url":"https://api.github.com/repos/golang/go/issues/10362","id":90556600,"user":{"login":"davecheney","id":7171,"avatar_url":"https://avatars.githubusercontent.com/u/7171?v=3","gravatar_id":"","url":"https://api.github.com/users/davecheney","html_url":"https://github.com/davecheney","followers_url":"https://api.github.com/users/davecheney/followers","following_url":"https://api.github.com/users/davecheney/following{/other_user}","gists_url":"https://api.github.com/users/davecheney/gists{/gist_id}","starred_url":"https://api.github.com/users/davecheney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davecheney/subscriptions","organizations_url":"https://api.github.com/users/davecheney/orgs","repos_url":"https://api.github.com/users/davecheney/repos","events_url":"https://api.github.com/users/davecheney/events{/privacy}","received_events_url":"https://api.github.com/users/davecheney/received_events","type":"User","site_admin":false},"created_at":"2015-04-07T13:37:40Z","updated_at":"2015-04-07T13:37:40Z","body":"This benchmark, shows the cliff when values pass the upper limit of DUFFCOPY\r\n\r\nhttp://paste.ubuntu.com/10762232/\r\n```\r\nroot@labs-782e8a:~/src/duffbench# go test -bench=.                                                                                                                        \r\ntesting: warning: no tests to run\r\nPASS\r\nBenchmarkCopy1          300000000                3.89 ns/op\r\nBenchmarkCopy4          50000000                40.0 ns/op\r\nBenchmarkCopy16         20000000                77.5 ns/op\r\nBenchmarkCopy32         20000000               139 ns/op\r\nBenchmarkCopy64          5000000               255 ns/op\r\nBenchmarkCopy128         3000000               538 ns/op\r\nBenchmarkCopy129         3000000               745 ns/op   <<<<\r\nBenchmarkCopy256         2000000              1088 ns/op\r\n```"}}