[llvm] [VectorCombine] Fold binary op of reductions. (PR #121567)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 12 04:39:50 PST 2025


================
@@ -1182,6 +1183,135 @@ bool VectorCombine::foldExtractedCmps(Instruction &I) {
   return true;
 }
 
+static void analyzeCostOfVecReduction(const IntrinsicInst &II,
+                                      TTI::TargetCostKind CostKind,
+                                      const TargetTransformInfo &TTI,
+                                      InstructionCost &CostBeforeReduction,
+                                      InstructionCost &CostAfterReduction) {
+  using namespace llvm::PatternMatch;
+  Instruction *Op0, *Op1;
+  Instruction *RedOp = dyn_cast<Instruction>(II.getOperand(0));
+  VectorType *VecRedTy = cast<VectorType>(II.getOperand(0)->getType());
+  unsigned ReductionOpc =
+      getArithmeticReductionInstruction(II.getIntrinsicID());
+  if (RedOp && match(RedOp, m_ZExtOrSExt(m_Value()))) {
+    bool IsUnsigned = isa<ZExtInst>(RedOp);
+    VectorType *ExtType =
+        cast<VectorType>(RedOp->getOperand(0)->getType());
----------------
RKSimon wrote:

(style) auto*

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


More information about the llvm-commits mailing list