diff options
author | Matthias Braun <matze@braunis.de> | 2022-05-03 10:53:34 -0700 |
---|---|---|
committer | Matthias Braun <matze@braunis.de> | 2022-05-10 10:00:10 -0700 |
commit | cd19af74c031f0f538050d00b26bab3fbca07414 (patch) | |
tree | 0133b92e1ad7dc8ac817a4451b369cf520623fa3 /llvm/lib/CodeGen/TargetLoweringBase.cpp | |
parent | 75e50f70c6fd461cae915fc4983faf4127a6059f (diff) | |
download | llvm-cd19af74c031f0f538050d00b26bab3fbca07414.zip llvm-cd19af74c031f0f538050d00b26bab3fbca07414.tar.gz llvm-cd19af74c031f0f538050d00b26bab3fbca07414.tar.bz2 |
Avoid 8 and 16bit switch conditions on x86
This adds a `TargetLoweringBase::getSwitchConditionType` callback to
give targets a chance to control the type used in
`CodeGenPrepare::optimizeSwitchInst`.
Implement callback for X86 to avoid i8 and i16 types where possible as
they often incur extra zero-extensions.
This is NFC for non-X86 targets.
Differential Revision: https://reviews.llvm.org/D124894
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringBase.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringBase.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp index 323c41c..63cac36 100644 --- a/llvm/lib/CodeGen/TargetLoweringBase.cpp +++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp @@ -1602,6 +1602,11 @@ bool TargetLoweringBase::isSuitableForJumpTable(const SwitchInst *SI, (NumCases * 100 >= Range * MinDensity); } +MVT TargetLoweringBase::getPreferredSwitchConditionType(LLVMContext &Context, + EVT ConditionVT) const { + return getRegisterType(Context, ConditionVT); +} + /// Get the EVTs and ArgFlags collections that represent the legalized return /// type of the given function. This does not require a DAG or a return value, /// and is suitable for use before any DAGs for the function are constructed. |