Handle guards uniformly with assumes, rather than iterating through all
block instructions in attempt to find them.
Details
Diff Detail
Unit Tests
Event Timeline
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.
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.
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.