[PATCH] D30333: Split SimplifyCFG to run obscuring switch transforms only during last phase

Joerg Sonnenberger via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 24 05:17:30 PST 2017


joerg created this revision.
Herald added a reviewer: deadalnix.

The SimplifyCFG pass currently contains two transformations for switches that can obscure flow and inhibit other optimisations:

1. switch of constants is replaced with look-up table
2. sparse switches are replaced with transformation of the condition to make them dense

Most importantly, both transformations can benefit from DCE as a result of CVP and inlining. At the same time, they can inhibit inlining when run before the corresponding module pass as part of the early function cleanup. Neither transform looks like it is very useful early on, so split the existing simplifycfg pass into two and replace the last instance in the normal pass pipeline with the latesimplifycfg pass.

Initial testing of a version covering only point (1) of the list above fixes the regression in PR 32003. A LNT run by Mehdi Amini of the same versions shows:
MultiSource/Benchmarks/ASC_Sequoia/CrystalMk/CrystalMk 2.5% slower
SingleSource/Benchmarks/Misc/matmul_f64_4x4 34.2% faster
SingleSource/Benchmarks/Misc/fp-convert 3.0% faster 
MultiSource/Benchmarks/Prolangs-C++/life/life 2.8% faster


https://reviews.llvm.org/D30333

Files:
  include/llvm-c/Transforms/Scalar.h
  include/llvm/InitializePasses.h
  include/llvm/LinkAllPasses.h
  include/llvm/Transforms/Scalar.h
  include/llvm/Transforms/Scalar/SimplifyCFG.h
  include/llvm/Transforms/Utils/Local.h
  lib/LTO/LTOCodeGenerator.cpp
  lib/Transforms/IPO/PassManagerBuilder.cpp
  lib/Transforms/Scalar/Scalar.cpp
  lib/Transforms/Scalar/SimplifyCFGPass.cpp
  lib/Transforms/Utils/SimplifyCFG.cpp
  test/Transforms/SimplifyCFG/ARM/switch-to-lookup-table.ll
  test/Transforms/SimplifyCFG/CoveredLookupTable.ll
  test/Transforms/SimplifyCFG/X86/switch-covered-bug.ll
  test/Transforms/SimplifyCFG/X86/switch-table-bug.ll
  test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll
  test/Transforms/SimplifyCFG/rangereduce.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30333.89652.patch
Type: text/x-patch
Size: 19924 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170224/c5a2e283/attachment.bin>


More information about the llvm-commits mailing list