[llvm] [IndVars] Support shl by constant and or disjoint in getExtendedOperandRecurrence. (PR #84282)

via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 6 22:47:30 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 2fcf248ec2614dd966f31d471a1a97989a76fd9d ce3d292b3339af4dc03c3a9e8499a31974acb300 -- llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
``````````

</details>

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

``````````diff
diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
index 7896f01913..f6d7226530 100644
--- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
@@ -1435,11 +1435,12 @@ static std::optional<BinaryOp> matchBinaryOp(Instruction *Op) {
         // requires special handling. It can be preserved as long as we're not
         // left shifting by bitwidth - 1.
         bool IsNUW = Op->hasNoUnsignedWrap();
-        bool IsNSW =
-            Op->hasNoSignedWrap() && (IsNUW || SA->getValue().ult(BitWidth - 1));
+        bool IsNSW = Op->hasNoSignedWrap() &&
+                     (IsNUW || SA->getValue().ult(BitWidth - 1));
 
-        ConstantInt *X = ConstantInt::get(
-            Op->getContext(), APInt::getOneBitSet(BitWidth, SA->getZExtValue()));
+        ConstantInt *X =
+            ConstantInt::get(Op->getContext(),
+                             APInt::getOneBitSet(BitWidth, SA->getZExtValue()));
         return BinaryOp(Instruction::Mul, Op->getOperand(0), X, IsNSW, IsNUW);
       }
     }
@@ -1463,12 +1464,13 @@ WidenIV::getExtendedOperandRecurrence(WidenIV::NarrowIVDefUse DU) {
     return {nullptr, ExtendKind::Unknown};
 
   assert((Op->Opcode == Instruction::Add || Op->Opcode == Instruction::Sub ||
-          Op->Opcode == Instruction::Mul) && "Unexpected opcode");
+          Op->Opcode == Instruction::Mul) &&
+         "Unexpected opcode");
 
   // One operand (NarrowDef) has already been extended to WideDef. Now determine
   // if extending the other will lead to a recurrence.
   const unsigned ExtendOperIdx = Op->Operands[0] == DU.NarrowDef ? 1 : 0;
-  assert(Op->Operands[1-ExtendOperIdx] == DU.NarrowDef && "bad DU");
+  assert(Op->Operands[1 - ExtendOperIdx] == DU.NarrowDef && "bad DU");
 
   ExtendKind ExtKind = getExtendKind(DU.NarrowDef);
   if (!(ExtKind == ExtendKind::Sign && Op->IsNSW) &&

``````````

</details>


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


More information about the llvm-commits mailing list