[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:05:41 PDT 2025
https://github.com/AZero13 created https://github.com/llvm/llvm-project/pull/146980
If X != Y, then X ^ Y != 0
>From 6605de7643e24aa72efa0df32b0edb50cd9cfbbd Mon Sep 17 00:00:00 2001
From: Rose <gfunni234 at gmail.com>
Date: Thu, 3 Jul 2025 21:04:49 -0400
Subject: [PATCH] ISD::XOR has the same non-zero detection as ISD::SUB
If X != Y, then X ^ Y != 0
---
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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);
More information about the llvm-commits
mailing list