[llvm] [InstCombine] Fold vector.reduce.op(vector.reverse(X)) -> vector.reduce.op(X) (PR #91743)
Paul Walker via llvm-commits
llvm-commits at lists.llvm.org
Wed May 15 07:01:21 PDT 2024
================
@@ -1435,6 +1435,51 @@ static Instruction *foldBitOrderCrossLogicOp(Value *V,
return nullptr;
}
+Instruction *InstCombinerImpl::simplifyReductionOfShuffle(IntrinsicInst *II) {
+ Intrinsic::ID IID = II->getIntrinsicID();
+ bool CanBeReassociated = (IID != Intrinsic::vector_reduce_fadd &&
+ IID != Intrinsic::vector_reduce_fmul) ||
+ II->hasAllowReassoc();
+
+ if (!CanBeReassociated)
+ return nullptr;
+
+ const unsigned ArgIdx = (IID == Intrinsic::vector_reduce_fadd ||
+ IID == Intrinsic::vector_reduce_fmul)
+ ? 1
+ : 0;
+ Value *Arg = II->getArgOperand(ArgIdx);
+ Value *V;
+
----------------
paulwalker-arm wrote:
That's not quite what I meant. I was more thinking `simplifyReductionOperand` would take the reduction's operand rather than the reduction itself. This way the reduction specific parts remain at the call site.
https://github.com/llvm/llvm-project/pull/91743
More information about the llvm-commits
mailing list