[PATCH] D28337: [InstSimplify] if the condition of a select is known, eliminate the select

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 9 13:38:52 PST 2017


spatel added a comment.

In https://reviews.llvm.org/D28337#640127, @majnemer wrote:

> In https://reviews.llvm.org/D28337#640118, @efriedma wrote:
>
> > This seems like a dangerous direction, in the sense that it could make instsimplify very expensive... I mean, if we didn't care about compile-time cost, we could call computeKnownBits on all the operands for every call into instsimplify, and hope something simplifies.  Could we put this sort of transform somewhere it isn't called so frequently?
>
>
> I agree, I'm not sure this is the right place for this.


Ok, thanks for the guidance. I see a couple of ways to limit the cost and still get the motivating case that has an 'llvm.assume':

1. Guard this call to computeKnownBits with a check of the select condition's users (make sure there's an assume in the list).
2. Trigger the fold from an earlier instruction via isKnownNonNullAt(). I think this would involve adding an llvm.assume check that's similar to the change in https://reviews.llvm.org/D20044. This probably also needs the extra isKnownNonNullAt() call from https://reviews.llvm.org/D28204.

Any others? Is one of the above preferable to the other?
Any


https://reviews.llvm.org/D28337





More information about the llvm-commits mailing list