[llvm] SelectionDAG: Fix widening of vector addrspacecast results (PR #217898)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 22 04:51:01 PDT 2026
================
@@ -6494,11 +6494,25 @@ SDValue DAGTypeLegalizer::WidenVecRes_MERGE_VALUES(SDNode *N, unsigned ResNo) {
}
SDValue DAGTypeLegalizer::WidenVecRes_ADDRSPACECAST(SDNode *N) {
+ SDLoc DL(N);
EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0));
- SDValue InOp = GetWidenedVector(N->getOperand(0));
+ ElementCount WidenEC = WidenVT.getVectorElementCount();
auto *AddrSpaceCastN = cast<AddrSpaceCastSDNode>(N);
- return DAG.getAddrSpaceCast(SDLoc(N), WidenVT, InOp,
+ // The source has the same number of elements as the result, so widen it to
+ // match WidenVT. It only lives in the widened-vector map if it is itself
+ // widened; otherwise pad it up to the widened element count.
+ SDValue InOp = N->getOperand(0);
+ EVT InVT = InOp.getValueType();
+ if (getTypeAction(InVT) == TargetLowering::TypeWidenVector) {
+ InOp = GetWidenedVector(InOp);
+ } else {
+ EVT InWidenVT = EVT::getVectorVT(*DAG.getContext(),
+ InVT.getVectorElementType(), WidenEC);
----------------
RKSimon wrote:
InVT.changeVectorElementCount() would work as well - but don't mind if you want to keep this.
https://github.com/llvm/llvm-project/pull/217898
More information about the llvm-commits
mailing list