[PATCH] D109151: [InstCombine] Convert xor (ashr X, BW-1), C -> select(X >=s 0, C, ~C)

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 7 01:40:53 PDT 2021


dmgreen added a comment.

> which brings me to the real question: isn't the main pattern here: https://alive2.llvm.org/ce/z/B8TUY6 ?

Not sure. This is already more general than I need it to be. I really just need this awkward saturate to fold into a more canonical pattern :)

A `select %c, -1, 0` is just a `sext c` (or in this case `select c, 0, -1 -> sext(not(c))`, which inverts the condition c). https://github.com/llvm/llvm-project/blob/c01b76e733d6e5e2d21e4277dceaa1f319794c6a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp#L1408 will convert that to a ashr. If you think any of that should change then let me know, but it seems like it might break a few things.


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

https://reviews.llvm.org/D109151



More information about the llvm-commits mailing list