[llvm] [InstCombine] Fold `(x < y) ? -1 : zext(x != y)` into `u/scmp(x,y)` (PR #101049)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 16 05:50:09 PDT 2024


================
@@ -3558,6 +3558,55 @@ static Instruction *foldBitCeil(SelectInst &SI, IRBuilderBase &Builder) {
                                 Masked);
 }
 
+// This function tries to fold the following operations:
+//   (x < y) ? -1 : zext(x != y)
+//   (x > y) ? 1 : sext(x != y)
+// Into ucmp/scmp(x, y), where signedness is determined by the signedness
+// of the comparison in the original sequence
----------------
nikic wrote:

```suggestion
// of the comparison in the original sequence.
```

https://github.com/llvm/llvm-project/pull/101049


More information about the llvm-commits mailing list