[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
Thu May 30 09:02:53 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) {
----------------
goldsteinn wrote:

Okay, created https://github.com/llvm/llvm-project/pull/93840

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


More information about the llvm-commits mailing list