[llvm-commits] [Patch] Use TargetTransformInfo to control switch-to-lookup table transform
Duncan Sands
baldrick at free.fr
Mon Oct 29 08:29:21 PDT 2012
Hi Hans,
> When the switch-to-lookup tables transform landed in SimplifyCFG, it
> was pointed out [1] that this could be inappropriate for some targets.
> Since there was no way at the time for the pass to know anything about
> the target, an awkward reverse-transform was added in CodeGenPrepare
> that turned lookup tables back into switches for some targets.
>
> The attached patch uses the new TargetTransformInfo to determine if a
> switch should be transformed, and removes
> CodeGenPrepare::ConvertLoadToSwitch. Please take a look!
personally I think it is completely wrong to have codegen concepts such as
ISD::BR_JT and ISD::BRIND leaking into the IR level:
> --- a/include/llvm/Transforms/Utils/Local.h
> +++ b/include/llvm/Transforms/Utils/Local.h
> @@ -49,6 +49,12 @@ unsigned ScalarTargetTransformImpl::getJumpBufSize() const {
> return TLI->getJumpBufSize();
> }
>
> +bool ScalarTargetTransformImpl::shouldBuildLookupTables() const {
> + return TLI->supportJumpTables() &&
> + (TLI->isOperationLegalOrCustom(ISD::BR_JT, MVT::Other) ||
> + TLI->isOperationLegalOrCustom(ISD::BRIND, MVT::Other));
> +}
> +
> //===----------------------------------------------------------------------===//
> //
> // Calls used by the vectorizers.
Ciao, Duncan.
More information about the llvm-commits
mailing list