[llvm] [ValueTracking][InstCombine] Fold add/or/xor to disjoint or using assume(no common bits) (PR #223344)

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 14 04:48:50 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- llvm/lib/Analysis/ValueTracking.cpp llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp llvm/unittests/Analysis/ValueTrackingTest.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 852a46cfa..b4295e4c0 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -244,7 +244,7 @@ haveNoCommonBitsSetSpecialCases(const Value *LHS, const Value *RHS,
 }
 
 static bool haveNoCommonBitsSetFromAssume(const Value *LHS, const Value *RHS,
-                                           const SimplifyQuery &SQ) {
+                                          const SimplifyQuery &SQ) {
   if (!SQ.AC || !SQ.CxtI)
     return false;
 
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index d43e0553a..da228c0e1 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -5491,8 +5491,8 @@ Instruction *InstCombinerImpl::visitXor(BinaryOperator &I) {
     return Xor;
 
   WithCache<const Value *> Op0Cache(Op0), Op1Cache(Op1);
-  switch (getNoCommonBitsSetResult(Op0Cache, Op1Cache,
-                                    SQ.getWithInstruction(&I))) {
+  switch (
+      getNoCommonBitsSetResult(Op0Cache, Op1Cache, SQ.getWithInstruction(&I))) {
   case NoCommonBitsSetResult::Known:
     return BinaryOperator::CreateDisjointOr(Op0, Op1);
   case NoCommonBitsSetResult::OnlyIfUndefIgnored:

``````````

</details>


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


More information about the llvm-commits mailing list