[llvm] [RISCV] Merge shuffle sources if lanes are disjoint (PR #119401)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 10 19:56:55 PST 2024
================
@@ -5540,6 +5601,16 @@ static SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG,
ShuffleMaskRHS.push_back(IsLHSOrUndefIndex ? -1 : (MaskIndex - NumElts));
}
+ // If the mask indices are disjoint between the two sources, we can lower it
+ // as a vselect + a single source vrgather.vv. Don't do this if the operands
+ // will be splatted since they will be lowered to something cheaper like
+ // vrgather.vi anyway.
+ if (!DAG.isSplatValue(V2) && !DAG.isSplatValue(V1) &&
----------------
lukel97 wrote:
Added the guard for the identity shuffle.
If isSplatMask is true for either source then the original lowering would have been a vrgather.vi + vrgather.vv at worse. So I don't think there would be much benefit to replacing that with vmerge.vvm + vrgather.vv, I attached an example diff in https://github.com/llvm/llvm-project/pull/119401#discussion_r1879288787
https://github.com/llvm/llvm-project/pull/119401
More information about the llvm-commits
mailing list