[llvm] 6dc3e22 - [DAGTypeLegalizer] Handle ZERO_EXTEND of promoted type in WidenVecRes_Convert.
Jonas Paulsson via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 8 07:54:58 PDT 2020
Author: Jonas Paulsson
Date: 2020-09-08T16:49:51+02:00
New Revision: 6dc3e22b575267d2ede36f741bb9eb2455f36cff
URL: https://github.com/llvm/llvm-project/commit/6dc3e22b575267d2ede36f741bb9eb2455f36cff
DIFF: https://github.com/llvm/llvm-project/commit/6dc3e22b575267d2ede36f741bb9eb2455f36cff.diff
LOG: [DAGTypeLegalizer] Handle ZERO_EXTEND of promoted type in WidenVecRes_Convert.
On SystemZ, a ZERO_EXTEND of an i1 vector handled by WidenVecRes_Convert()
always ended up being scalarized, because the type action of the input is
promotion which was previously an unhandled case in this method.
This fixes https://bugs.llvm.org/show_bug.cgi?id=47132.
Differential Revision: https://reviews.llvm.org/D86268
Patch by Eli Friedman.
Review: Ulrich Weigand
Added:
Modified:
llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
llvm/test/CodeGen/SystemZ/vec-zext.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
index 093f7b1680ed..764472e570c0 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
@@ -3307,19 +3307,34 @@ SDValue DAGTypeLegalizer::WidenVecRes_OverflowOp(SDNode *N, unsigned ResNo) {
}
SDValue DAGTypeLegalizer::WidenVecRes_Convert(SDNode *N) {
+ LLVMContext &Ctx = *DAG.getContext();
SDValue InOp = N->getOperand(0);
SDLoc DL(N);
- EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0));
+ EVT WidenVT = TLI.getTypeToTransformTo(Ctx, N->getValueType(0));
unsigned WidenNumElts = WidenVT.getVectorNumElements();
EVT InVT = InOp.getValueType();
- EVT InEltVT = InVT.getVectorElementType();
- EVT InWidenVT = EVT::getVectorVT(*DAG.getContext(), InEltVT, WidenNumElts);
unsigned Opcode = N->getOpcode();
- unsigned InVTNumElts = InVT.getVectorNumElements();
const SDNodeFlags Flags = N->getFlags();
+
+ // Handle the case of ZERO_EXTEND where the promoted InVT element size does
+ // not equal that of WidenVT.
+ if (N->getOpcode() == ISD::ZERO_EXTEND &&
+ getTypeAction(InVT) == TargetLowering::TypePromoteInteger &&
+ TLI.getTypeToTransformTo(Ctx, InVT).getScalarSizeInBits() !=
+ WidenVT.getScalarSizeInBits()) {
+ InOp = ZExtPromotedInteger(InOp);
+ InVT = InOp.getValueType();
+ if (WidenVT.getScalarSizeInBits() < InVT.getScalarSizeInBits())
+ Opcode = ISD::TRUNCATE;
+ }
+
+ EVT InEltVT = InVT.getVectorElementType();
+ EVT InWidenVT = EVT::getVectorVT(Ctx, InEltVT, WidenNumElts);
+ unsigned InVTNumElts = InVT.getVectorNumElements();
+
if (getTypeAction(InVT) == TargetLowering::TypeWidenVector) {
InOp = GetWidenedVector(N->getOperand(0));
InVT = InOp.getValueType();
diff --git a/llvm/test/CodeGen/SystemZ/vec-zext.ll b/llvm/test/CodeGen/SystemZ/vec-zext.ll
index b4c8f2307b0b..cb61d31e5ebe 100644
--- a/llvm/test/CodeGen/SystemZ/vec-zext.ll
+++ b/llvm/test/CodeGen/SystemZ/vec-zext.ll
@@ -92,3 +92,19 @@ define <8 x i16> @fun10(<8 x i8> %val1) {
ret <8 x i16> %z
}
+define <2 x i32> @fun11(<2 x i64> %Arg1, <2 x i64> %Arg2) {
+; CHECK-LABEL: fun11:
+; CHECK: vgbm %v0, 0
+; CHECK-NEXT: vceqg %v1, %v24, %v0
+; CHECK-NEXT: vceqg %v0, %v26, %v0
+; CHECK-NEXT: vo %v0, %v1, %v0
+; CHECK-NEXT: vrepig %v1, 1
+; CHECK-NEXT: vn %v0, %v0, %v1
+; CHECK-NEXT: vpkg %v24, %v0, %v0
+; CHECK-NEXT: br %r14
+ %i3 = icmp eq <2 x i64> %Arg1, zeroinitializer
+ %i5 = icmp eq <2 x i64> %Arg2, zeroinitializer
+ %i6 = or <2 x i1> %i3, %i5
+ %i7 = zext <2 x i1> %i6 to <2 x i32>
+ ret <2 x i32> %i7
+}
More information about the llvm-commits
mailing list