[PATCH] D97092: [ValueTracking] Handle assumes on arguments with context instruction

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 22 13:40:54 PST 2021


jdoerfert added a comment.

In D97092#2579184 <https://reviews.llvm.org/D97092#2579184>, @reames wrote:

> One idea on an alternate approach we could explore...
>
> In the langref, we have an alternate way of spelling assumes using operand bundles.  The key advantage of that approach (in the context of this discussion), is that there are no ephemeral icmps generated.  We still have to concern ourselves with not eliminating assumes, but at least the assumes are themselves direct uses of the values we're inferring facts about.

I think operand bundles are not "accidentally" removed. Assumption simplification should avoid cyclic reasoning but that seems doable in a specific pass.

> If we were to extend the operand bundle syntax to allow arbitrary predicates, we could allow the use of the operand bundle assumes without a context, and simply restrict transform passes from *directly* simplifying assume operands.  The only tricky case I see here is equalities as CSE would tend to replace the operands in the deopt bundle if e.g. instsimplify knew two values were equivalent from the assume.  (I haven't fully thought this through.)



> If we do pursue this, we'd need to untangle the operand bundle form handling from the knowledge transfer work, but that doesn't seem challenging.  I'm not sure why those are coupled currently anyways.

Because that was the only use case. Untangling is eventually needed.

In D97092#2579797 <https://reviews.llvm.org/D97092#2579797>, @nikic wrote:

> Just to clarify one thing: The (general) ephemeral value problem is a bit more complicated in that we actually *do* want to fold assume conditions -- just not on themselves. For example, if you have `assume(x > 0); assume(x > 1);`, then it is expected that the second assume gets folded away, because it is implied by the first and thus redundant. I don't think assume operand bundles fundamentally change the picture here, they just make it easier to identify ephemeral values.

It does because you can identify assume uses easily. So you can ask if `x > 1` is known not using the particular use of `x` for the reasoning.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97092/new/

https://reviews.llvm.org/D97092



More information about the llvm-commits mailing list