[PATCH] D77868: [InstSimplify] fold select of bools using bitwise logic

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 10 08:53:28 PDT 2020


nikic added a comment.

In D77868#1974322 <https://reviews.llvm.org/D77868#1974322>, @spatel wrote:

> In D77868#1974228 <https://reviews.llvm.org/D77868#1974228>, @nikic wrote:
>
> > What is the motivation for having this fold partially (only if recursively simplifiable) in InstSimplify, rather than doing the full fold in InstCombine?
>
>
> If the logic can be simplified, then that makes it poison-safe. Ie, if the logic op simplifies, that means the logic op must be filtering out a poisoned value the same as we would expect of a select. Does that make sense, or do you know of a counter-example?


Sorry, my original question didn't make sense... I'm having a really hard time convincing myself that this is correct though. If we simplify to a constant, that's obviously correct. If we simplify to some value on which the select condition depends, then it's also correct (as the condition does not block poison). But can't it also happen that we simplify to a value that the select operand depends on, but the condition does not? I wasn't able to come up with a specific example, but I'm not immediately seeing why that couldn't happen, in principle.


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

https://reviews.llvm.org/D77868





More information about the llvm-commits mailing list