[llvm] [InstCombine, AArch64] Avoid vector Ext in case by-element operation variant apply for all elements (PR #140733)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue May 20 07:15:35 PDT 2025
================
@@ -18602,6 +18602,33 @@ static SDValue performBuildShuffleExtendCombine(SDValue BV, SelectionDAG &DAG) {
SeenZExtOrSExt = true;
}
+ // Avoid the said use of vector SExt/ZExt in case all vector elements are
+ // consumed and each shuffle's mask uses same index, in order to permit use of
+ // indexed OP (e.g. MLA, MUL) variants
+ EVT ExtendType = Extend->getValueType(0);
+ if (ExtendType.isVector() && !ExtendType.isScalableVT()) {
+ const int NumElements = ExtendType.getVectorNumElements();
+ SmallBitVector UsedElements(NumElements, false);
+ for (auto UI = Extend.getNode()->use_begin(),
+ UE = Extend.getNode()->use_end();
+ UI != UE; ++UI) {
+ SDNode *User = UI->getUser();
+ if (User->getOpcode() == ISD::VECTOR_SHUFFLE &&
+ User->getOperand(0) == Extend) {
----------------
fhahn wrote:
Might be simpler to invert the condition and have the exit early for users that don't satisfy our check + a comment of what we are looking for
https://github.com/llvm/llvm-project/pull/140733
More information about the llvm-commits
mailing list