This is an archive of the discontinued LLVM Phabricator instance.

[SCEV][NFC][CT] Cheaper handling of guards in isBasicBlockEntryGuardedByCond
ClosedPublic

Authored by mkazantsev on Jul 15 2022, 9:13 AM.

Details

Summary

Handle guards uniformly with assumes, rather than iterating through all
block instructions in attempt to find them.

Diff Detail

Event Timeline

mkazantsev created this revision.Jul 15 2022, 9:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 15 2022, 9:13 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
mkazantsev requested review of this revision.Jul 15 2022, 9:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 15 2022, 9:13 AM
nikic accepted this revision.Jul 18 2022, 5:51 AM

LG if this is faster for you in practice.

Though I do have to wonder: Why are we not tracking guard intrinsics in AssumptionCache? Iterating over users of the declaration has the disadvantage that you may be looking at guards in many other functions, and that it will run into issues when we try to parallelize the pass manager. It seems like tracking them in AC the same way as assumptions shouldn't be too hard.

This revision is now accepted and ready to land.Jul 18 2022, 5:51 AM

Good question. I guess we just never got to do it. And parallelizing the PM will face much more problem than that. For example, we sometimes see a situation in SCEV when condition A implies B, but when we simplify A (e.g. replace with invariant), B is not always implyable. How many of these do we have - I don't know.

LG if this is faster for you in practice.

Though I do have to wonder: Why are we not tracking guard intrinsics in AssumptionCache? Iterating over users of the declaration has the disadvantage that you may be looking at guards in many other functions, and that it will run into issues when we try to parallelize the pass manager. It seems like tracking them in AC the same way as assumptions shouldn't be too hard.

We don't really see impact because SCEV in our pipeline takes negligible time far less than noise. :( But hypothetically, this should be better because guards are not so numerous usually.

This revision was landed with ongoing or failed builds.Jul 24 2022, 11:39 PM
This revision was automatically updated to reflect the committed changes.