[llvm] [InstCombine] Resolve FIXME: Use commutative matchers (PR #81060)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 7 16:33:59 PST 2024
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 43badc0a9644d032fe0176410fabda6ac1fddf19 0956b09cf07d8c6a6d5b9fb674efa739524621b7 -- llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
index 1a10b5c474..0dc18cfedb 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
@@ -1532,7 +1532,7 @@ Instruction *InstCombinerImpl::visitAdd(BinaryOperator &I) {
// (A + C1) + (C2 - B) --> (A - B) + (C1 + C2)
Constant *C1, *C2;
if (match(&I, m_Add(m_c_Add(m_Value(A), m_ImmConstant(C1)),
- m_Sub(m_ImmConstant(C2), m_Value(B)))) &&
+ m_Sub(m_ImmConstant(C2), m_Value(B)))) &&
(LHS->hasOneUse() || RHS->hasOneUse())) {
Value *Sub = Builder.CreateSub(A, B);
return BinaryOperator::CreateAdd(Sub, ConstantExpr::getAdd(C1, C2));
@@ -1618,9 +1618,9 @@ Instruction *InstCombinerImpl::visitAdd(BinaryOperator &I) {
// Canonicalize ((A & -A) - 1) --> ((A - 1) & ~A)
// Forms all commutable operations, and simplifies ctpop -> cttz folds.
- if (match(&I, m_Add(m_OneUse(m_c_And(m_Value(A),
- m_OneUse(m_Neg(m_Deferred(A))))),
- m_AllOnes()))) {
+ if (match(&I,
+ m_Add(m_OneUse(m_c_And(m_Value(A), m_OneUse(m_Neg(m_Deferred(A))))),
+ m_AllOnes()))) {
Constant *AllOnes = ConstantInt::getAllOnesValue(RHS->getType());
Value *Dec = Builder.CreateAdd(A, AllOnes);
Value *Not = Builder.CreateXor(A, AllOnes);
@@ -1643,9 +1643,8 @@ Instruction *InstCombinerImpl::visitAdd(BinaryOperator &I) {
// (A * -2**C) + B --> B - (A << C)
const APInt *NegPow2C;
- if (match(&I,
- m_c_Add(m_OneUse(m_Mul(m_Value(A), m_NegatedPower2(NegPow2C))),
- m_Value(B)))) {
+ if (match(&I, m_c_Add(m_OneUse(m_Mul(m_Value(A), m_NegatedPower2(NegPow2C))),
+ m_Value(B)))) {
Constant *ShiftAmtC = ConstantInt::get(Ty, NegPow2C->countr_zero());
Value *Shl = Builder.CreateShl(A, ShiftAmtC);
return BinaryOperator::CreateSub(B, Shl);
``````````
</details>
https://github.com/llvm/llvm-project/pull/81060
More information about the llvm-commits
mailing list