[PATCH] D107233: [SimplifyCFG] Enable switch to lookup table for more types.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 31 16:50:55 PDT 2021


craig.topper created this revision.
craig.topper added reviewers: efriedma, lebedev.ri, spatel, asb, luismarques.
Herald added subscribers: StephenFan, frasercrmck, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, kristof.beyls.
craig.topper requested review of this revision.
Herald added a subscriber: MaskRay.
Herald added a project: LLVM.

This transform has been restricted to legal types since
https://reviews.llvm.org/rG65df808f6254617b9eee931d00e95d900610b660
in 2012.

This is particularly restrictive on RISCV64 which only has i64
as a legal integer type. i32 is a very common type in code
generated from C, but we won't form a lookup table with it.
This also effects other common types like i8/i16 types on ARM,
AArch64, RISCV, etc.

This patch proposes to allow power of 2 types larger than 8 bit, if
they will fit in the largest legal integer type in DataLayout.
These types are common in C code so generally well handled in
the backends.

We could probably do this for other types like i24 and rely on
alignment and padding to allow the backend to use a single wider
load. This isn't my main concern right now and it will need more
tests.

We could also allow larger types up to some limit and let the
backend split into multiple loads, but we need to define that
limit. It's also not my main concern right now.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107233

Files:
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp
  llvm/test/Transforms/SimplifyCFG/RISCV/switch_to_lookup_table-rv32.ll
  llvm/test/Transforms/SimplifyCFG/RISCV/switch_to_lookup_table-rv64.ll
  llvm/test/Transforms/SimplifyCFG/rangereduce.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107233.363326.patch
Type: text/x-patch
Size: 21332 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210731/4ede948c/attachment.bin>


More information about the llvm-commits mailing list