From b9f282d384fc9b94734ffdf5e505b772a889b214 Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Tue, 23 Apr 2019 21:30:30 +0000 Subject: [WebAssembly] Emit br_table for most switch instructions Summary: Always convert switches to br_tables unless there is only one case, which is equivalent to a simple branch. This reduces code size for wasm, and we defer possible jump table optimizations to the VM. Addresses PR41502. Reviewers: kripken, sunfish Subscribers: dschuff, sbc100, jgravelle-google, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D60966 llvm-svn: 359038 --- llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp') diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp index 7bad4972c4f..105b1360ac2 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp @@ -270,6 +270,11 @@ WebAssemblyTargetLowering::WebAssemblyTargetLowering( MaxStoresPerMemset = 1; MaxStoresPerMemsetOptSize = 1; } + + // Always convert switches to br_tables unless there is only one case, which + // is equivalent to a simple branch. This reduces code size for wasm, and we + // defer possible jump table optimizations to the VM. + setMinimumJumpTableEntries(2); } TargetLowering::AtomicExpansionKind -- cgit v1.2.3