[PATCH] D123494: [VectorCombine] Find and remove shuffles from commutative reductions

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 11 04:12:29 PDT 2022


dmgreen added inline comments.


================
Comment at: llvm/test/Transforms/VectorCombine/AArch64/vecreduce-shuffle.ll:20
+; CHECK-NEXT:    [[X:%.*]] = shufflevector <4 x i32> [[A:%.*]], <4 x i32> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
 ; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[X]])
 ; CHECK-NEXT:    ret i32 [[R]]
----------------
RKSimon wrote:
> What about we start with a much simpler combine in InstSimplify/Combine that just removes a permute it is feeds a commutative reduction?
We already have that combine in https://github.com/llvm/llvm-project/blob/431e93f4f56e5b839bf1f746d65139ccf3ca2232/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp#L2601.

This is trying to add a more complex version for vector combine that can handle more patterns, and potentially remove more shuffles that are cheaper than the original (not just single-input identity masks).

This test I wanted to leave in to make sure there was vector-combine testing for it, even if the simpler combine exists elsewhere too.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123494/new/

https://reviews.llvm.org/D123494



More information about the llvm-commits mailing list