[llvm] ISD::XOR has the same non-zero detection as ISD::SUB (PR #146980)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 3 18:06:10 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-selectiondag

Author: AZero13 (AZero13)

<details>
<summary>Changes</summary>

If X != Y, then X ^ Y != 0

---
Full diff: https://github.com/llvm/llvm-project/pull/146980.diff


1 Files Affected:

- (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (+1-1) 


``````````diff
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 6df21b624137f..4e9cebb881deb 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -6016,7 +6016,7 @@ bool SelectionDAG::isKnownNeverZero(SDValue Op, unsigned Depth) const {
         return true;
     // TODO: There are a lot more cases we can prove for add.
     break;
-
+  case ISD::XOR:
   case ISD::SUB: {
     if (isNullConstant(Op.getOperand(0)))
       return isKnownNeverZero(Op.getOperand(1), Depth + 1);

``````````

</details>


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


More information about the llvm-commits mailing list