[llvm] [InstCombine] Fold `(op x, ({z,s}ext (icmp eq x, C)))` to select (PR #89020)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 17 01:45:38 PDT 2024
================
@@ -4734,6 +4734,89 @@ void InstCombinerImpl::tryToSinkInstructionDbgValues(
}
}
+// If we have:
+// `(op X, (zext/sext (icmp eq X, C)))`
+// We can transform it to:
+// `(select (icmp eq X, C), (op C, (zext/sext 1)), (op X, 0))`
+// We do so if the `zext/sext` is one use and `(op X, 0)` simplifies.
+Value *InstCombinerImpl::foldOpOfXWithXEqC(Value *Op, const SimplifyQuery &SQ) {
----------------
XChy wrote:
If I remember correctly, similar patterns like `X * (X != 0) -> X` exist already. Can they be folded here too?
https://github.com/llvm/llvm-project/pull/89020
More information about the llvm-commits
mailing list