[llvm] Match the inverse of m_AddOverflow (PR #147215)

via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 6 14:00:25 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,h -- llvm/include/llvm/IR/PatternMatch.h llvm/lib/CodeGen/CodeGenPrepare.cpp llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
``````````

</details>

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

``````````diff
diff --git a/llvm/include/llvm/IR/PatternMatch.h b/llvm/include/llvm/IR/PatternMatch.h
index 36e88fa78..2faacbca6 100644
--- a/llvm/include/llvm/IR/PatternMatch.h
+++ b/llvm/include/llvm/IR/PatternMatch.h
@@ -2669,7 +2669,8 @@ m_UAddWithOverflow(const LHS_t &L, const RHS_t &R, const Sum_t &S) {
   return UAddWithOverflow_match<LHS_t, RHS_t, Sum_t>(L, R, S);
 }
 
-/// Match an icmp instruction checking for unsigned overflow on addition, but with the opposite check.
+/// Match an icmp instruction checking for unsigned overflow on addition, but
+/// with the opposite check.
 ///
 /// S is matched to the addition whose result is being checked for overflow, and
 /// L and R are matched to the LHS and RHS of S.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 662ef154f..694de16fd 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -7833,12 +7833,12 @@ Instruction *InstCombinerImpl::visitICmpInst(ICmpInst &I) {
     }
 
     if (match(&I, m_UAddWithOverflowInv(m_Value(X), m_Value(Y),
-                                     m_Instruction(AddI))) &&
+                                        m_Instruction(AddI))) &&
         isa<IntegerType>(X->getType())) {
       Value *Result;
       Constant *Overflow;
-      // m_UAddWithOverflowInv can match patterns that do not include an explicit
-      // "add" instruction, so check the opcode of the matched op.
+      // m_UAddWithOverflowInv can match patterns that do not include an
+      // explicit "add" instruction, so check the opcode of the matched op.
       if (AddI->getOpcode() == Instruction::Add &&
           OptimizeOverflowCheck(Instruction::Add, /*Signed*/ false, X, Y, *AddI,
                                 Result, Overflow)) {

``````````

</details>


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


More information about the llvm-commits mailing list