[llvm] [InstCombine] Propagate exact flags in shift-combine transforms (PR #88340)

via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 18 17:51:59 PDT 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 396cdabe47f3596464b289d0937c0066f50a0ac6 483c2cb81a8d189223f56427adb255ab009b9aa5 -- llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
``````````

</details>

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

``````````diff
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
index 1cac4f3954..9fa711556f 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
@@ -1401,7 +1401,8 @@ Instruction *InstCombinerImpl::visitLShr(BinaryOperator &I) {
       if (AmtSum < BitWidth) {
         auto *NewLShr =
             BinaryOperator::CreateLShr(X, ConstantInt::get(Ty, AmtSum));
-        NewLShr->setIsExact(I.isExact() && cast<BinaryOperator>(Op0)->isExact());
+        NewLShr->setIsExact(I.isExact() &&
+                            cast<BinaryOperator>(Op0)->isExact());
         return NewLShr;
       }
     }
@@ -1640,7 +1641,8 @@ Instruction *InstCombinerImpl::visitAShr(BinaryOperator &I) {
       // Oversized arithmetic shifts replicate the sign bit.
       AmtSum = std::min(AmtSum, BitWidth - 1);
       // (X >>s C1) >>s C2 --> X >>s (C1 + C2)
-      Instruction *NewAshr = BinaryOperator::CreateAShr(X, ConstantInt::get(Ty, AmtSum));
+      Instruction *NewAshr =
+          BinaryOperator::CreateAShr(X, ConstantInt::get(Ty, AmtSum));
       NewAshr->setIsExact(I.isExact() && cast<BinaryOperator>(Op0)->isExact());
       return NewAshr;
     }

``````````

</details>


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


More information about the llvm-commits mailing list