{"action":"created","issue":{"url":"https://api.github.com/repos/kripken/emscripten/issues/4789","repository_url":"https://api.github.com/repos/kripken/emscripten","labels_url":"https://api.github.com/repos/kripken/emscripten/issues/4789/labels{/name}","comments_url":"https://api.github.com/repos/kripken/emscripten/issues/4789/comments","events_url":"https://api.github.com/repos/kripken/emscripten/issues/4789/events","html_url":"https://github.com/kripken/emscripten/issues/4789","id":194873823,"number":4789,"title":"emcc does not lower too-large vector types","user":{"login":"allanlw","id":1410954,"avatar_url":"https://avatars.githubusercontent.com/u/1410954?v=3","gravatar_id":"","url":"https://api.github.com/users/allanlw","html_url":"https://github.com/allanlw","followers_url":"https://api.github.com/users/allanlw/followers","following_url":"https://api.github.com/users/allanlw/following{/other_user}","gists_url":"https://api.github.com/users/allanlw/gists{/gist_id}","starred_url":"https://api.github.com/users/allanlw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allanlw/subscriptions","organizations_url":"https://api.github.com/users/allanlw/orgs","repos_url":"https://api.github.com/users/allanlw/repos","events_url":"https://api.github.com/users/allanlw/events{/privacy}","received_events_url":"https://api.github.com/users/allanlw/received_events","type":"User","site_admin":false},"labels":[{"id":129271303,"url":"https://api.github.com/repos/kripken/emscripten/labels/SIMD","name":"SIMD","color":"bfd4f2","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-12-12T01:38:04Z","updated_at":"2016-12-13T21:43:35Z","closed_at":null,"body":"Consider the following program:\r\n\r\n``` c\r\n#include <stdio.h>\r\n\r\n#define vs 4\r\n#define vt double\r\n\r\ntypedef vt myvector __attribute__ ((vector_size (sizeof(vt) * vs)));\r\n\r\nint main() {\r\n  myvector a = {0}, b = {0};\r\n  for (int i = 0; i < vs; i++) { a[i] = i; b[i] = i; }\r\n\r\n  a *= b;\r\n\r\n  for (int i = 0; i < vs; i++) {\r\n    printf(\"%f\\n\", a[i]);\r\n  }\r\n}\r\n\r\n```\r\n\r\nemcc fails to compile this with an unexplained assertion error: `LLVM ERROR: VT->getBitWidth() <= 128`, but clang and GCC handle it fine. The solution is to lower the too-large SIMD types until they are of supported width."},"comment":{"url":"https://api.github.com/repos/kripken/emscripten/issues/comments/266871206","html_url":"https://github.com/kripken/emscripten/issues/4789#issuecomment-266871206","issue_url":"https://api.github.com/repos/kripken/emscripten/issues/4789","id":266871206,"user":{"login":"dschuff","id":1122856,"avatar_url":"https://avatars.githubusercontent.com/u/1122856?v=3","gravatar_id":"","url":"https://api.github.com/users/dschuff","html_url":"https://github.com/dschuff","followers_url":"https://api.github.com/users/dschuff/followers","following_url":"https://api.github.com/users/dschuff/following{/other_user}","gists_url":"https://api.github.com/users/dschuff/gists{/gist_id}","starred_url":"https://api.github.com/users/dschuff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dschuff/subscriptions","organizations_url":"https://api.github.com/users/dschuff/orgs","repos_url":"https://api.github.com/users/dschuff/repos","events_url":"https://api.github.com/users/dschuff/events{/privacy}","received_events_url":"https://api.github.com/users/dschuff/received_events","type":"User","site_admin":false},"created_at":"2016-12-13T21:43:34Z","updated_at":"2016-12-13T21:43:34Z","body":"LLVM does normally handle this via target-independent SelectionDAG code,\nand you are correct that skipping that is the reason that fastcomp doesn't\nsupport this functionality. It could be done via an LLVM IR pass (the way\nthe rest of the type \"lowering\" is done in fastcomp); my guess is that it's\nstraightforward in principle but tricky in practice. When WebAssembly gets\nSIMD support (which we expect to have essentially the same functionality as\nthe SIMD.js spec) the upstream wasm backend should support it via the\nconventional mechanisms. In fact there's a bit of proto-SIMD support there\nalready which needs fleshing out (obviously it also needs an implementation\nin a wasm engine which isn't exposed yet either).\n\nOn Tue, Dec 13, 2016 at 6:19 AM Allan Wirth <notifications@github.com>\nwrote:\n\n> In my specific case I don't care about SIMD speedups per-se, I care about\n> compiling an existing codebase that uses vectors that are too large and\n> expects the compiler to lower them.\n>\n> My impression is that LLVM normally does this through TargetLowering but\n> that emscripten skips the SelectionDAG stuff altogether, so this machinery\n> can't be reused. Doing this through an opt pass might not be too bad, to\n> lower into, say an array of vectors, although some care would need to be\n> taken to implement gather and scatter and to make sure that a later pass\n> does not re-vectorize. Perhaps for the more complex vector intrinsics, it\n> might be easier to not replace them inline and instead call out to a\n> polyfill function.\n>\n> I might take a crack at writing such an opt pass if I ever get some free\n> time.\n>\n> —\n> You are receiving this because you are subscribed to this thread.\n> Reply to this email directly, view it on GitHub\n> <https://github.com/kripken/emscripten/issues/4789#issuecomment-266749796>,\n> or mute the thread\n> <https://github.com/notifications/unsubscribe-auth/ABEiKJc7rPcxy2HS1CncQZXjHH96glwXks5rHql0gaJpZM4LKHH9>\n> .\n>\n"}}
{"actor":{"display_login":"dschuff"}}