[llvm] SelectionDAG: Don't pad the source of ADDRSPACECAST if it's legal. (PR #225390)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 22 06:06:37 PDT 2026
https://github.com/sujianIBM created https://github.com/llvm/llvm-project/pull/225390
With this use case `%out = addrspacecast <2 x ptr> %in to <2 x ptr addrspace(1)>` on z/OS, the res type is `v2i32` (illegal) and the source type is `v2i64` (legal).
Padding the source up to `v4i64` makes it illegal on z/OS and breaks the type legalization.
>From daea9f84eeab62ce29482eb31c34594ec42c6a72 Mon Sep 17 00:00:00 2001
From: Jian Su <jian.su at ibm.com>
Date: Tue, 22 Sep 2026 12:35:16 +0000
Subject: [PATCH] Don't pad the source of ADDRSPACECAST if it's legal.
---
llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
index 48fc990700b3c..624fa69a6e023 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
@@ -6333,12 +6333,13 @@ SDValue DAGTypeLegalizer::WidenVecRes_ADDRSPACECAST(SDNode *N) {
// 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.
+ // widened; otherwise pad it up to the widened element count
+ // when it is illegal.
SDValue InOp = N->getOperand(0);
EVT InVT = InOp.getValueType();
if (getTypeAction(InVT) == TargetLowering::TypeWidenVector) {
InOp = GetWidenedVector(InOp);
- } else {
+ } else if (getTypeAction(InVT) != TargetLowering::TypeLegal) {
EVT InWidenVT = EVT::getVectorVT(*DAG.getContext(),
InVT.getVectorElementType(), WidenEC);
InOp = DAG.getInsertSubvector(DL, DAG.getPOISON(InWidenVT), InOp, 0);
More information about the llvm-commits
mailing list