forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit af80969
authored
[NFC] SimplifyCFG: Detect switch replacement earlier in
This PR is the first part to solve the issue in llvm#149937.
The end goal is enabling more switch optimizations on targets that do
not support lookup tables.
SimplifyCFG has the ability to replace switches with either a few simple
calculations, a single value, or a lookup table.
However, it only considers these options if the target supports lookup
tables, even if the final result is not a LUT, but a few simple
instructions like muls, adds and shifts.
To enable more targets to use these other kinds of optimization, this PR
restructures the code in `switchToLookup`.
Previously, code was generated even before choosing what kind of
replacement to do. However, we need to know if we actually want to
create a true LUT or not before generating anything. Then we can check
for target support only if any LUT would be created.
This PR moves the code so it first determines the replacement kind and
then generates the instructions.
A later PR will insert the target support check after determining the
kind of replacement. If the result is not a LUT, then even targets
without LUT support can replace the switch with something else.switchToLookup (llvm#155602)1 parent 74b7e73 commit af80969Copy full SHA for af80969
File tree
Expand file treeCollapse file tree
1 file changed
+145
-124
lines changedOpen diff view settings
Filter options
- llvm/lib/Transforms/Utils
Expand file treeCollapse file tree
1 file changed
+145
-124
lines changedOpen diff view settings
0 commit comments