[llvm] [InstCombine] Detect uadd with overflow idiom (PR #140178)

via llvm-commits llvm-commits at lists.llvm.org
Fri May 16 09:58:37 PDT 2025


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 HEAD~1 HEAD --extensions cpp -- llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
``````````

</details>

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

``````````diff
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 303c90661..865923ad7 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -6565,9 +6565,9 @@ static Instruction *processUZExtIdiom(ICmpInst &I, Value *Val,
     ResultType = TyA;
   }
 
-  // In order to replace the original result with an add/mul.with.overflow intrinsic,
-  // all uses must ignore upper bits of the result.  The number of used low
-  // bits must be not greater than the width of add/mul.with.overflow.
+  // In order to replace the original result with an add/mul.with.overflow
+  // intrinsic, all uses must ignore upper bits of the result.  The number of
+  // used low bits must be not greater than the width of add/mul.with.overflow.
   if (Val->hasNUsesOrMore(2))
     for (User *U : Val->users()) {
       if (U == &I)
@@ -6656,7 +6656,8 @@ static Instruction *processUZExtIdiom(ICmpInst &I, Value *Val,
           TI->setOperand(0, Extract);
       } else if (BinaryOperator *BO = dyn_cast<BinaryOperator>(U)) {
         assert(BO->getOpcode() == Instruction::And);
-        // Replace (Extract & mask) --> zext (add/mul.with.overflow & short_mask)
+        // Replace (Extract & mask) --> zext (add/mul.with.overflow &
+        // short_mask)
         ConstantInt *CI = cast<ConstantInt>(BO->getOperand(1));
         APInt ShortMask = CI->getValue().trunc(ResultWidth);
         Value *ShortAnd = Builder.CreateAnd(Extract, ShortMask);

``````````

</details>


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


More information about the llvm-commits mailing list