[llvm] [ValueTracking] X ^ Y != 0 if X != Y. (PR #146975)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 3 17:46:15 PDT 2025
https://github.com/AZero13 updated https://github.com/llvm/llvm-project/pull/146975
>From e66fb58a8d773deec8a2a6dfd7b9683c56e1c083 Mon Sep 17 00:00:00 2001
From: Rose <gfunni234 at gmail.com>
Date: Thu, 3 Jul 2025 19:55:09 -0400
Subject: [PATCH] [ValueTracking] X ^ Y != 0 if X != Y.
It goes without saying that for x ^ y to be 0, x and y must be equal.
---
llvm/lib/Analysis/ValueTracking.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index e576f4899810a..ba8ae3a975729 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -3043,6 +3043,10 @@ static bool isKnownNonZeroFromOperator(const Operator *I,
// (X ^ (X != 0)) is non zero
if (matchOpWithOpEqZero(I->getOperand(0), I->getOperand(1)))
return true;
+ // X ^ Y != 0 if X != Y.
+ if (isKnownNonEqual(I->getOperand(0), I->getOperand(1), DemandedElts, Q,
+ Depth))
+ return true;
break;
case Instruction::Or:
// (X | (X != 0)) is non zero
More information about the llvm-commits
mailing list