Skip to content

Commit 275e9bb

Browse files
committed
Turn off Vectorization for Emscripten
When targeting Emscripten, rustc emits Vector Instructions by default. However Web Assembly doesn't support Vector Instructions yet, which causes Binaryen to fail converting the intermediate asm.js code to Web Assembly. While asm.js kind of supports Vector Instructions, they aren't supported by any browser other than Firefox, often meaning that they need to be emulated very slowly. So it should just be turned off for all Emscripten targets. Fixes #38558
1 parent 5b7c556 commit 275e9bb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/librustc_trans/back/write.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,15 @@ impl ModuleConfig {
315315
// Copy what clang does by turning on loop vectorization at O2 and
316316
// slp vectorization at O3. Otherwise configure other optimization aspects
317317
// of this pass manager builder.
318+
// Turn off vectorization for emscripten, as it's not very well supported.
318319
self.vectorize_loop = !sess.opts.cg.no_vectorize_loops &&
319320
(sess.opts.optimize == config::OptLevel::Default ||
320-
sess.opts.optimize == config::OptLevel::Aggressive);
321+
sess.opts.optimize == config::OptLevel::Aggressive) &&
322+
!sess.target.target.options.is_like_emscripten;
323+
321324
self.vectorize_slp = !sess.opts.cg.no_vectorize_slp &&
322-
sess.opts.optimize == config::OptLevel::Aggressive;
325+
sess.opts.optimize == config::OptLevel::Aggressive &&
326+
!sess.target.target.options.is_like_emscripten;
323327

324328
self.merge_functions = sess.opts.optimize == config::OptLevel::Default ||
325329
sess.opts.optimize == config::OptLevel::Aggressive;

0 commit comments

Comments
 (0)