[llvm-commits] [llvm] r167011 - in /llvm/trunk: include/llvm/Target/TargetTransformImpl.h include/llvm/TargetTransformInfo.h include/llvm/Transforms/Utils/Local.h lib/Target/TargetTransformImpl.cpp lib/Transforms/Scalar/CodeGenPrepare.cpp lib/Transforms/Scalar/SimplifyCFGPass.cpp lib/Transforms/Utils/SimplifyCFG.cpp test/CodeGen/SPARC/load_to_switch.ll test/Transforms/SimplifyCFG/SPARC/ test/Transforms/SimplifyCFG/SPARC/lit.local.cfg test/Transforms/SimplifyCFG/SPARC/switch_to_lookup_table.ll

Andrew Trick atrick at apple.com
Tue Nov 6 23:04:47 PST 2012


On Oct 30, 2012, at 4:23 AM, Hans Wennborg <hans at hanshq.net> wrote:
> --- llvm/trunk/include/llvm/TargetTransformInfo.h (original)
> +++ llvm/trunk/include/llvm/TargetTransformInfo.h Tue Oct 30 06:23:25 2012
> @@ -117,6 +117,11 @@
>   virtual unsigned getJumpBufSize() const {
>     return 0;
>   }
> +  /// shouldBuildLookupTables - Return true if switches should be turned into
> +  /// lookup tables for the target.
> +  virtual bool shouldBuildLookupTables() const {
> +    return true;
> +  }
> };

> Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=167011&r1=167010&r2=167011&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
> +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Tue Oct 30 06:23:25 2012
> 
> @@ -3459,8 +3462,13 @@
> /// replace the switch with lookup tables.
> static bool SwitchToLookupTable(SwitchInst *SI,
>                                 IRBuilder<> &Builder,
> -                                const DataLayout* TD) {
> +                                const DataLayout* TD,
> +                                const TargetTransformInfo *TTI) {
>   assert(SI->getNumCases() > 1 && "Degenerate switch?");
> +
> +  if (TTI && !TTI->getScalarTargetTransformInfo()->shouldBuildLookupTables())
> +    return false;
> +


Hi Hans,

The two cases above assume that lookup tables should be generated whenever TargetTransformInfo is missing or unspecified. It is important to be able to run the opt tool without target information and later rerun certain optimizations for a specific target, or simply run the code generator.

Please explain how this can work for a target that doesn't expect lookup tables. You've removed the lookup-table-to-switch codegen transform, so how can a target undo the effect of target-independent optimization now?

I realize you expect to expose further analysis by converting to tables, but is it really important to generate lookup-tables when target info is not provided?

-Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121106/50e419de/attachment.html>


More information about the llvm-commits mailing list