[PATCH] D23396: [Assumptions] Make collecting ephemeral values not quadratic in the number of assume intrinsics.

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 11 02:48:31 PDT 2016


chandlerc created this revision.
chandlerc added reviewers: sanjoy, hfinkel.
chandlerc added a subscriber: llvm-commits.
Herald added a subscriber: mcrosier.

The classical way to have a cache-friendly vector style container when
we need queue semantics for BFS instead of stack semantics for DFS is to
use an ever-growing vector and an index. Erasing from the front requires
O(size) work, and unless we expect the worklist to grow *very* large,
its probably cheaper to just grow and race down the list.

But that makes it more bad that we're putting the assume intrinsics in
this at all. We end up looking at the (by definition empty) use list to
see if they're ephemeral (when we've already put them in that set), etc.

Instead, directly populate the worklist with the operands when we mark
the assume intrinsics as ephemeral. Also, test the visited set *before*
putting things into the worklist so we don't accumulate the same value
in the list 100s of times.

It would be nice to use a set-vector for this but I think its useful to
test the set earlier to avoid repeatedly querying whether the same
instruction is safe to speculate.

Hopefully with these changes the number of values pushed onto the
worklist is smaller, and we avoid quadratic work by letting it grow as
necessary.

https://reviews.llvm.org/D23396

Files:
  lib/Analysis/CodeMetrics.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23396.67665.patch
Type: text/x-patch
Size: 3987 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160811/12f2fa9a/attachment.bin>


More information about the llvm-commits mailing list