[PATCH] D41029: [JumpTables][PowerPC] Let targets decide which switch instructions are suitable for jump tables

Nemanja Ivanovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 8 12:27:03 PST 2017


nemanjai created this revision.

As currently implemented, the decision whether a particular switch instruction is suitable for a jump table is made in the base class of `TargetLowering`. So the only control a target has is to allow or disallow emission of jump tables.
However, there is at least one target (PowerPC) and possibly others for which that decision depends on a bit more context than just the range and density.

This patch allows the targets to override these functions as well as provides the PowerPC overrides.

The PPC specific portion:

- No jump tables for small switches - there's a lot of overhead to set up a jump table due to use of the CTR and high-latency sign-extending load
- Avoid chaining moves to the CTR and branches on the CTR (when the target of a case has an indirect call, a CTR loop or another possible jump table)
- Avoid multiple CTR branches close together to avoid the possibility of branch aliasing (when the block terminated by the switch has an indirect call or explicit use of the CTR)


Repository:
  rL LLVM

https://reviews.llvm.org/D41029

Files:
  include/llvm/CodeGen/TargetLowering.h
  lib/Target/PowerPC/PPCISelLowering.cpp
  lib/Target/PowerPC/PPCISelLowering.h
  test/CodeGen/PowerPC/NoJTsDueToCTRUse.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41029.126193.patch
Type: text/x-patch
Size: 19589 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171208/2de14419/attachment.bin>


More information about the llvm-commits mailing list