[llvm] [AMDGPU] Legalize 64bit elements for BUILD_VECTOR on gfx942 (PR #145052)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 1 01:03:50 PDT 2025
================
@@ -14385,6 +14404,27 @@ SITargetLowering::performExtractVectorEltCombine(SDNode *N,
}
}
+ // if PeekThoughBitcast(Vec)[MapIdx(CIdx)] == undef &&
+ // VecEltSize < PeekThroughEltSize, then
+ // EXTRACT_VECTOR_ELT(bitcast(build_vector(..., undef, ...)), CIdx) => undef
+ auto *IndexC = dyn_cast<ConstantSDNode>(N->getOperand(1));
+ SDValue PeekThroughVec = peekThroughBitcasts(Vec);
+ EVT PeekThroughVecVT = PeekThroughVec.getValueType();
+ if (IndexC && PeekThroughVec.getOpcode() == ISD::BUILD_VECTOR &&
+ PeekThroughVecVT.isFixedLengthVector()) {
+ EVT PeekThroughVecEltVT = PeekThroughVecVT.getVectorElementType();
+ // Small elt size vectors to big elt size vectors are the cases covered for
+ // now (e.g., v4i32 bitcast(v2i64)) which may be conservative.
+ if (VecEltSize < PeekThroughVecEltVT.getSizeInBits()) {
+ unsigned IndexVal = IndexC->getZExtValue();
+ unsigned MappedIndexVal =
+ getMappedVectorIndex(IndexVal, VecVT, PeekThroughVecVT);
+ SDValue PeekThroughElt = PeekThroughVec.getOperand(MappedIndexVal);
+ if (PeekThroughElt.isUndef())
+ return DAG.getUNDEF(VecEltVT);
----------------
arsenm wrote:
isUndef returns true for ISD::UNDEF and ISD::POISON, this will unconditionally use UNDEF instead of POISON
https://github.com/llvm/llvm-project/pull/145052
More information about the llvm-commits
mailing list