{"action":"created","issue":{"url":"https://api.github.com/repos/johnmccutchan/ecmascript_simd/issues/182","labels_url":"https://api.github.com/repos/johnmccutchan/ecmascript_simd/issues/182/labels{/name}","comments_url":"https://api.github.com/repos/johnmccutchan/ecmascript_simd/issues/182/comments","events_url":"https://api.github.com/repos/johnmccutchan/ecmascript_simd/issues/182/events","html_url":"https://github.com/johnmccutchan/ecmascript_simd/issues/182","id":81645320,"number":182,"title":"Revisit swizzle/shuffle support","user":{"login":"jfbastien","id":298127,"avatar_url":"https://avatars.githubusercontent.com/u/298127?v=3","gravatar_id":"","url":"https://api.github.com/users/jfbastien","html_url":"https://github.com/jfbastien","followers_url":"https://api.github.com/users/jfbastien/followers","following_url":"https://api.github.com/users/jfbastien/following{/other_user}","gists_url":"https://api.github.com/users/jfbastien/gists{/gist_id}","starred_url":"https://api.github.com/users/jfbastien/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfbastien/subscriptions","organizations_url":"https://api.github.com/users/jfbastien/orgs","repos_url":"https://api.github.com/users/jfbastien/repos","events_url":"https://api.github.com/users/jfbastien/events{/privacy}","received_events_url":"https://api.github.com/users/jfbastien/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-05-27T22:06:01Z","updated_at":"2015-05-29T14:19:50Z","closed_at":null,"body":"I wouldn't expose swizzle and shuffle, at least not in the initial SIMD.js version.\r\n\r\nIf this is unacceptable, I would at least only allow swizzle/shuffle with constant integer masks, not variable masks.\r\n\r\n--\r\n\r\nSwizzle / shuffle as of issue #1 take constant *or* variable masks. The variable masks are slow on most ISAs and require the client-side compiler to deconstruct them. SIMD.js is a performance-oriented feature, it seems silly to expose a glassjaw API. @littledan suggests relying on the asm.js spec to mandate constant-mask swizzle/shuffle, but I find the priority inversion where JavaScript-relies-on-asm.js to be undesirable.\r\n\r\nFurthermore, the C++ standards committee is currently in the early stage of standardizing fixed-width SIMD, it would be unfortunate to diverge considering C++ compilers will likely be the main generators of SIMD.js code. The current discussion (not yet published) around swizzle/shuffle is to support shuffles with two input vectors and a constant integer mask. The should be published by Chandler Carruth and Matthias Kretz.\r\n\r\nIt's also unclear if the swizzle/shuffle mask is allowed to widen or narrow vectors if SIMD.js ends up supporting vectors sizes other than 128-bits: Can I shuffle 2 vectors 4xi32 into a 8xi64? Can I shuffle one 4xf32 into 2xf32?\r\n\r\nSIMD.js' currently proposed vector insert/extract also don't require constant insert/extract, though this is less of a performance issue.\r\n\r\nThe initial SIMD.js API could only expose insert/extract and detect relevant patterns at code generation time. This may lead to JavaScript engine implementation pain.\r\n\r\nIf swizzle/shuffle is exposed, then maybe constant integer masks can be exposed through `Math` object magic?"},"comment":{"url":"https://api.github.com/repos/johnmccutchan/ecmascript_simd/issues/comments/106823365","html_url":"https://github.com/johnmccutchan/ecmascript_simd/issues/182#issuecomment-106823365","issue_url":"https://api.github.com/repos/johnmccutchan/ecmascript_simd/issues/182","id":106823365,"user":{"login":"johnmccutchan","id":224266,"avatar_url":"https://avatars.githubusercontent.com/u/224266?v=3","gravatar_id":"","url":"https://api.github.com/users/johnmccutchan","html_url":"https://github.com/johnmccutchan","followers_url":"https://api.github.com/users/johnmccutchan/followers","following_url":"https://api.github.com/users/johnmccutchan/following{/other_user}","gists_url":"https://api.github.com/users/johnmccutchan/gists{/gist_id}","starred_url":"https://api.github.com/users/johnmccutchan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnmccutchan/subscriptions","organizations_url":"https://api.github.com/users/johnmccutchan/orgs","repos_url":"https://api.github.com/users/johnmccutchan/repos","events_url":"https://api.github.com/users/johnmccutchan/events{/privacy}","received_events_url":"https://api.github.com/users/johnmccutchan/received_events","type":"User","site_admin":false},"created_at":"2015-05-29T14:19:50Z","updated_at":"2015-05-29T14:19:50Z","body":"The enumerated shuffle masks (e.g. .xyzw) were constant but there was no way to guarantee that the input passed to the shuffle method was a constant. Developers are capable and intelligent, they can easily understand the following rule: If your shuffle masks are not constants, the compiler will not optimize your code.\r\n\r\nWhere is the C++ standard committee's approach documented? "}}