Skip to content

Conversation

@AZero13
Copy link
Contributor

@AZero13 AZero13 commented Jul 4, 2025

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

@llvmbot llvmbot added the llvm:SelectionDAG SelectionDAGISel as well label Jul 4, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 4, 2025

@llvm/pr-subscribers-backend-x86

@llvm/pr-subscribers-llvm-selectiondag

Author: AZero13 (AZero13)

Changes

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 --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);

@AZero13 AZero13 marked this pull request as draft July 4, 2025 01:51
@AZero13 AZero13 marked this pull request as ready for review July 4, 2025 14:06
@AZero13 AZero13 changed the title ISD::XOR has the same non-zero detection as ISD::SUB [SelectionDAG] ISD::XOR has the same non-zero detection as ISD::SUB Jul 5, 2025
@topperc
Copy link
Collaborator

topperc commented Jul 5, 2025

Your second commit doesn't seem to change any tests?

@AZero13 AZero13 closed this Jul 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend:X86 llvm:SelectionDAG SelectionDAGISel as well

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants