[PATCH] D41361: [SimplifyCFG] Avoid quadratic on a predecessors number behavior in instruction sinking.

Michael Zolotukhin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 18 10:47:52 PST 2017


mzolotukhin created this revision.
mzolotukhin added reviewers: jmolloy, spatel.
Herald added subscribers: kristof.beyls, javed.absar, aemerson.

If a block has N predecessors, then the current algorithm will try to
sink common code to this block N times (whenever we visit a
predecessor). Every attempt to sink the common code includes going
through all predecessors, so the complexity of the algorithm becomes
O(N^2).
With this patch we try to sink common code only when we visit the block
itself. With this, the complexity goes down to O(N).
As a side effect, the moment the code is sunk is slightly different than
before (the order of simplifications has been changed), that's why I had
to adjust two tests (note that neither of the tests is supposed to test
SimplifyCFG):

- test/CodeGen/AArch64/arm64-jumptable.ll - changes in this test mimic

the changes that previous implementation of SimplifyCFG would do.

- test/CodeGen/ARM/avoid-cpsr-rmw.ll - in this test I disabled common

code sinking by a command line flag.


https://reviews.llvm.org/D41361

Files:
  lib/Transforms/Utils/SimplifyCFG.cpp
  test/CodeGen/AArch64/arm64-jumptable.ll
  test/CodeGen/ARM/avoid-cpsr-rmw.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41361.127388.patch
Type: text/x-patch
Size: 4338 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171218/beaeb377/attachment.bin>


More information about the llvm-commits mailing list