[llvm] [InstCombine] Remove redundant shift folds (NFCI) (PR #90016)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 24 21:59:40 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Nikita Popov (nikic)
<details>
<summary>Changes</summary>
These are already handled by canEvaluateShifted/getShiftedValue (one-use only), and also in reassociateShiftAmtsOfTwoSameDirectionShifts (also multi-use), so let's at least get rid of the *third* implementation...
---
Full diff: https://github.com/llvm/llvm-project/pull/90016.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp (-16)
``````````diff
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
index 244f03a1bc2b4c..1cb21a1d81af4b 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
@@ -1120,14 +1120,6 @@ Instruction *InstCombinerImpl::visitShl(BinaryOperator &I) {
return BinaryOperator::CreateAnd(Trunc, ConstantInt::get(Ty, Mask));
}
- if (match(Op0, m_Shl(m_Value(X), m_APInt(C1))) && C1->ult(BitWidth)) {
- unsigned AmtSum = ShAmtC + C1->getZExtValue();
- // Oversized shifts are simplified to zero in InstSimplify.
- if (AmtSum < BitWidth)
- // (X << C1) << C2 --> X << (C1 + C2)
- return BinaryOperator::CreateShl(X, ConstantInt::get(Ty, AmtSum));
- }
-
// If we have an opposite shift by the same amount, we may be able to
// reorder binops and shifts to eliminate math/logic.
auto isSuitableBinOpcode = [](Instruction::BinaryOps BinOpcode) {
@@ -1394,14 +1386,6 @@ Instruction *InstCombinerImpl::visitLShr(BinaryOperator &I) {
}
}
- // (X >>u C1) >>u C --> X >>u (C1 + C)
- if (match(Op0, m_LShr(m_Value(X), m_APInt(C1)))) {
- // Oversized shifts are simplified to zero in InstSimplify.
- unsigned AmtSum = ShAmtC + C1->getZExtValue();
- if (AmtSum < BitWidth)
- return BinaryOperator::CreateLShr(X, ConstantInt::get(Ty, AmtSum));
- }
-
Instruction *TruncSrc;
if (match(Op0, m_OneUse(m_Trunc(m_Instruction(TruncSrc)))) &&
match(TruncSrc, m_LShr(m_Value(X), m_APInt(C1)))) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/90016
More information about the llvm-commits
mailing list