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

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 13 10:12:23 PDT 2020


nikic added a comment.

Let me try to give a specific example. Let's say we're looking at the `select Cond, T, false --> Cond & T` case and have:

  Cond = X ult 10
  T = (X +nuw 1) ult 11

In this case, InstSimplify would be permitted to fold `Cond & T` to `T`: http://volta.cs.utah.edu:8080/z/KcVHTj

However, it would not be legal to perform the same transform for the `select`: http://volta.cs.utah.edu:8080/z/tM_9UA

Now, InstSimplify doesn't perform this particular fold (and it makes little sense to fold `Cond & T` to `T` rather than `Cond` in this example), but I think this illustrates that the transform is not inherently safe.


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

https://reviews.llvm.org/D77868





More information about the llvm-commits mailing list