[PATCH] D27259: Make processing @llvm.assume more efficient - operand bundles

Hal Finkel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 30 08:39:53 PST 2016


hfinkel created this revision.
hfinkel added reviewers: Prazek, chandlerc, sanjoy, wash.
hfinkel added subscribers: llvm-commits, sanjoy.
Herald added subscribers: mcrosier, jholewinski.

There is an efficiency problem with how we process `@llvm.assume` in ValueTracking (and other places). The AssumptionCache tracks all of the assumptions in a given function. In order to find assumptions relevant to computing known bits, etc. we search every assumption in the function. For ValueTracking that means that we do O(#assumes * #values) work in InstCombine and other passes (with a constant factor that can be quite large because we'll repeat this search at every level  of recursion of the analysis).

Several of us discussed this situation at the last developers' meeting, and here's the first step toward implementing the discussed solution: Make the values that an assume might affect operands of the assume itself. To avoid exposing this detail to frontends and passes that need not worry about it, I've used the new operand-bundle feature to add these extra call "operands" in a way that does not affect the intrinsic's signature. I think this solution is relatively clean. InstCombine adds these extra operands based on what ValueTracking, LVI, etc. will need and then those passes need only search the users of the values under consideration. This should fix the computational complexity problem.

My goal is to use this scheme to remove the need for the AssumptionCache all together. The only user not removed by the current patch is ScalarEvolution. @sanjoy, do you have a good idea of how this might be done? I looked at the handing of the guard intrinsics in SE, and it looks like we should handle both the same way, although the handling of the guard intrinsics seems to involve a lot of basic-block scanning, and I'd hope there was a more-efficient way.


https://reviews.llvm.org/D27259

Files:
  lib/Analysis/CodeMetrics.cpp
  lib/Analysis/LazyValueInfo.cpp
  lib/Analysis/ValueTracking.cpp
  lib/Transforms/InstCombine/InstCombineCalls.cpp
  lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
  test/Transforms/CorrelatedValuePropagation/conflict.ll
  test/Transforms/InstCombine/assume-redundant.ll
  test/Transforms/InstCombine/assume.ll
  test/Transforms/InstCombine/assume2.ll
  test/Transforms/InstSimplify/add-mask.ll
  test/Transforms/JumpThreading/assume-edge-dom.ll
  test/Transforms/JumpThreading/assume.ll
  test/Transforms/NaryReassociate/NVPTX/nary-gep.ll
  test/Transforms/SimplifyCFG/switch-dead-default.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27259.79744.patch
Type: text/x-patch
Size: 19225 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161130/c5d5d35a/attachment.bin>


More information about the llvm-commits mailing list