[PATCH] D35411: [SimplifyCFG] Defer folding unconditional branches to LateSimplifyCFG if it can destroy canonical loop structure.

Balaram Makam via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 14 05:13:37 PDT 2017


bmakam created this revision.
Herald added a subscriber: javed.absar.

When simplifying unconditional branches from empty blocks, we pre-test if the
BB belongs to a set of loop headers and keep the block to prevent passes from
destroying canonical loop structure. However, the current algorithm fails if
the destination of the branch is a loop header. Especially when such a loop's
latch block is folded into loop header it results in additional backedges and
LoopSimplify turns it into a nested loop which prevent later optimizations
from being applied (e.g., loop  unrolling and loop interleaving).

This patch augments the existing algorithm by further checking if the
destination of the branch belongs to a set of loop headers and defer
eliminating it if yes to LateSimplifyCFG.

Fixes PR33605: https://bugs.llvm.org/show_bug.cgi?id=33605


https://reviews.llvm.org/D35411

Files:
  lib/CodeGen/CodeGenPrepare.cpp
  lib/Transforms/Scalar/JumpThreading.cpp
  lib/Transforms/Utils/SimplifyCFG.cpp
  test/CodeGen/AArch64/aarch64-loop-gep-opt.ll
  test/Transforms/JumpThreading/static-profile.ll
  test/Transforms/LoopUnroll/peel-loop.ll
  test/Transforms/LoopUnroll/pr33605.ll
  test/Transforms/LoopUnswitch/2015-06-17-Metadata.ll
  test/Transforms/LoopUnswitch/infinite-loop.ll
  test/Transforms/LoopVectorize/X86/float-induction-x86.ll
  test/Transforms/LoopVectorize/float-induction.ll
  test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll
  test/Transforms/SimplifyCFG/multiple-phis.ll
  test/Transforms/SimplifyCFG/preserve-llvm-loop-metadata.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35411.106623.patch
Type: text/x-patch
Size: 15834 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170714/f38731ca/attachment.bin>


More information about the llvm-commits mailing list