{"action":"created","issue":{"url":"https://api.github.com/repos/johnmccutchan/ecmascript_simd/issues/72","labels_url":"https://api.github.com/repos/johnmccutchan/ecmascript_simd/issues/72/labels{/name}","comments_url":"https://api.github.com/repos/johnmccutchan/ecmascript_simd/issues/72/comments","events_url":"https://api.github.com/repos/johnmccutchan/ecmascript_simd/issues/72/events","html_url":"https://github.com/johnmccutchan/ecmascript_simd/issues/72","id":43979179,"number":72,"title":"shift behavior with out-of-range count","user":{"login":"sunfishcode","id":4503403,"avatar_url":"https://avatars.githubusercontent.com/u/4503403?v=3","gravatar_id":"","url":"https://api.github.com/users/sunfishcode","html_url":"https://github.com/sunfishcode","followers_url":"https://api.github.com/users/sunfishcode/followers","following_url":"https://api.github.com/users/sunfishcode/following{/other_user}","gists_url":"https://api.github.com/users/sunfishcode/gists{/gist_id}","starred_url":"https://api.github.com/users/sunfishcode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sunfishcode/subscriptions","organizations_url":"https://api.github.com/users/sunfishcode/orgs","repos_url":"https://api.github.com/users/sunfishcode/repos","events_url":"https://api.github.com/users/sunfishcode/events{/privacy}","received_events_url":"https://api.github.com/users/sunfishcode/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2014-09-25T23:14:42Z","updated_at":"2015-01-13T17:07:23Z","closed_at":null,"body":"What should the spec say for shiftLeft, shiftRightLogical, and shiftRightArithmetic, when the shift count is greater than the bitwidth of the vector element? Obvious choices include:\r\n\r\n - wrap the count modulo the bitwidth (regular JS shifts do this, and so that's what the polyfill currently does)\r\n - return 0 (or -1 for shiftRightArithmetic when applicable) (x86 vector shifts do this)\r\n - unspecified whether it's either of the above\r\n - undefined value\r\n\r\nFully undefined is undesirable, because it's handy to be able to make rotate sequences like (x >> n)|(x << (32 - n)) and have it work properly when n is 0, but any of the other choices would work for that.\r\n\r\nARM doesn't appear to support variable-count vector shifts, so it doesn't give us guidance here (although we note in passing that this will be an unavoidable performance cliff).\r\n\r\nI don't have a strong argument here, other than observing that returning 0/-1 is conceptually cleaner for a shift operation, and that also avoids extra overhead on x86."},"comment":{"url":"https://api.github.com/repos/johnmccutchan/ecmascript_simd/issues/comments/69779712","html_url":"https://github.com/johnmccutchan/ecmascript_simd/issues/72#issuecomment-69779712","issue_url":"https://api.github.com/repos/johnmccutchan/ecmascript_simd/issues/72","id":69779712,"user":{"login":"bnjbvr","id":1180019,"avatar_url":"https://avatars.githubusercontent.com/u/1180019?v=3","gravatar_id":"","url":"https://api.github.com/users/bnjbvr","html_url":"https://github.com/bnjbvr","followers_url":"https://api.github.com/users/bnjbvr/followers","following_url":"https://api.github.com/users/bnjbvr/following{/other_user}","gists_url":"https://api.github.com/users/bnjbvr/gists{/gist_id}","starred_url":"https://api.github.com/users/bnjbvr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bnjbvr/subscriptions","organizations_url":"https://api.github.com/users/bnjbvr/orgs","repos_url":"https://api.github.com/users/bnjbvr/repos","events_url":"https://api.github.com/users/bnjbvr/events{/privacy}","received_events_url":"https://api.github.com/users/bnjbvr/received_events","type":"User","site_admin":false},"created_at":"2015-01-13T17:07:23Z","updated_at":"2015-01-13T17:07:23Z","body":"Another issue with the same source: what should happen when the shift count is actually negative?\r\nCurrent behavior in the polyfill is the same as in JavaScript, which is to put the shift count in the range [0, 32[ by adding multiples of 32 (i.e. `x << -1 === x << (32-1)`).\r\n\r\n@sunfishcode, your PR looks nice and I'd love to see this move forward. A few remarks:\r\n- there are tests only for int32x4, not for other types.\r\n- implementation is different between int32x4.{shiftLeftByScalar,shiftRightLogicalByScalar} (which return splat(0)) and other types/shifts. Maybe it would be nice to make it uniform between types and functions?\r\n\r\nCan we add this to the topic list for the next face to face meeting?"}}