This is an archive of the discontinued LLVM Phabricator instance.

[EarlyCSE] infer conditional equalities within basic blocks
AbandonedPublic

Authored by reames on Jan 3 2017, 7:20 PM.

Details

Summary

Both llvm.experimental.guard and llvm.assume intrinsics can introduce facts in the middle of a basic block. Previously, EarlyCSE was not exploiting these facts when visiting later instructions in the same block.

Worth noting is that the choice to visit each operand does make the algorithm O(n^2) in the number of instructions. However, this is not new. We have to hash the operands, so we're already O(n^2). Apparently, most real code doesn't consist of long series of calls which consume each previous instruction. Who knew?

Diff Detail

Event Timeline

reames updated this revision to Diff 82993.Jan 3 2017, 7:20 PM
reames retitled this revision from to [EarlyCSE] infer conditional equalities within basic blocks.
reames updated this object.
reames added reviewers: sanjoy, hfinkel, gberry, majnemer.
reames added a subscriber: llvm-commits.
reames updated this revision to Diff 82994.Jan 3 2017, 7:28 PM

fix the bug I noticed immediate after uploading the first version...

sanjoy requested changes to this revision.Jan 4 2017, 9:39 PM
sanjoy edited edge metadata.

Comments inline.

lib/Transforms/Scalar/EarlyCSE.cpp
620

In the pathological case that you mentioned won't this be O(I^3), since you're doing:

for each Inst in BB:
  for each operand I of Inst:
    for each operand X of I:
      hash(X)

Maybe we can find an better bound as a function of the number of total uses?

674

This bit is NFC right (just adds the debug output)? If so, I'd just land this without review.

test/Transforms/EarlyCSE/guards.ll
195

This will get the case where the second guard was using %cond1 = <same expression as %cond0> right? If so, please add a test case that checks that.

This revision now requires changes to proceed.Jan 4 2017, 9:39 PM
reames abandoned this revision.Feb 10 2017, 9:59 AM
reames added a reviewer: mkazantsev.

Abandoning the revision as I don't have time to get back to this. mkazantsev will be picking up this line of work and will be posting a revised patch at some point in the not to distant future.