[llvm] [vectorcombine] Pull sext/zext through reduce.or/and/xor (PR #99548)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 18 12:01:26 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 5e8cd29d62a72ed18e7bc782554d7f14eccec0ee 044926bef56b6999082f09295b295a0a2fb7f8fa --extensions cpp -- llvm/lib/Transforms/Vectorize/VectorCombine.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index de60d80aef..854bde1491 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -2140,14 +2140,13 @@ bool VectorCombine::foldCastFromReductions(Instruction &I) {
Value *Src;
if (!match(ReductionSrc, m_OneUse(m_Trunc(m_Value(Src)))) &&
- (TruncOnly ||
- !match(ReductionSrc, m_OneUse(m_ZExtOrSExt(m_Value(Src))))))
+ (TruncOnly || !match(ReductionSrc, m_OneUse(m_ZExtOrSExt(m_Value(Src))))))
return false;
// Note: Only trunc has a constexpr, neither sext or zext do.
auto CastOpc = Instruction::Trunc;
if (auto *Cast = dyn_cast<CastInst>(ReductionSrc))
- CastOpc = (Instruction::CastOps)cast<Instruction>(Cast)->getOpcode();
+ CastOpc = (Instruction::CastOps)cast<Instruction>(Cast)->getOpcode();
auto *SrcTy = cast<VectorType>(Src->getType());
auto *ReductionSrcTy = cast<VectorType>(ReductionSrc->getType());
@@ -2157,21 +2156,19 @@ bool VectorCombine::foldCastFromReductions(Instruction &I) {
InstructionCost OldCost = TTI.getArithmeticReductionCost(
ReductionOpc, ReductionSrcTy, std::nullopt, CostKind);
if (auto *Cast = dyn_cast<CastInst>(ReductionSrc))
- OldCost +=
- TTI.getCastInstrCost(CastOpc, ReductionSrcTy, SrcTy,
- TTI::CastContextHint::None, CostKind, Cast);
+ OldCost += TTI.getCastInstrCost(CastOpc, ReductionSrcTy, SrcTy,
+ TTI::CastContextHint::None, CostKind, Cast);
InstructionCost NewCost =
TTI.getArithmeticReductionCost(ReductionOpc, SrcTy, std::nullopt,
CostKind) +
- TTI.getCastInstrCost(CastOpc, ResultTy,
- ReductionSrcTy->getScalarType(),
+ TTI.getCastInstrCost(CastOpc, ResultTy, ReductionSrcTy->getScalarType(),
TTI::CastContextHint::None, CostKind);
if (OldCost <= NewCost || !NewCost.isValid())
return false;
- Value *NewReduction = Builder.CreateIntrinsic(
- SrcTy->getScalarType(), II->getIntrinsicID(), {Src});
+ Value *NewReduction = Builder.CreateIntrinsic(SrcTy->getScalarType(),
+ II->getIntrinsicID(), {Src});
Value *NewCast = Builder.CreateCast(CastOpc, NewReduction, ResultTy);
replaceValue(I, *NewCast);
return true;
``````````
</details>
https://github.com/llvm/llvm-project/pull/99548
More information about the llvm-commits
mailing list