From e31cf3f824786e020f4dea9ad216a65538f8a630 Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Fri, 21 Apr 2017 20:35:52 +0000 Subject: [PATCH] ARM: make sure we use all entries in a vector before forming a vpaddl. Otherwise there's some mismatch, and we'll either form an illegal type or an illegal node. Thanks to Eli Friedman for pointing out the problem with my original solution. llvm-svn: 301036 --- llvm/lib/Target/ARM/ARMISelLowering.cpp | 10 +++++----- llvm/test/CodeGen/ARM/vpadd.ll | 9 +++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp index df840d723e3b..382f881f7741 100644 --- a/llvm/lib/Target/ARM/ARMISelLowering.cpp +++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp @@ -9480,11 +9480,11 @@ AddCombineBUILD_VECTORToVPADDL(SDNode *N, SDValue N0, SDValue N1, return SDValue(); } - // Don't generate vpaddl+vmovn; we'll match it to vpadd later. Also don't try - // to handle an i8 -> i32 situation (or similar). vpaddl can only double the - // size. - if (2 * Vec.getValueType().getVectorElementType().getSizeInBits() != - VT.getVectorElementType().getSizeInBits()) + // Don't generate vpaddl+vmovn; we'll match it to vpadd later. Also make sure + // we're using the entire input vector, otherwise there's a size/legality + // mismatch somewhere. + if (nextIndex != Vec.getValueType().getVectorNumElements() || + Vec.getValueType().getVectorElementType() == VT.getVectorElementType()) return SDValue(); // Create VPADDL node. diff --git a/llvm/test/CodeGen/ARM/vpadd.ll b/llvm/test/CodeGen/ARM/vpadd.ll index 9720f801029d..3409d37a31f4 100644 --- a/llvm/test/CodeGen/ARM/vpadd.ll +++ b/llvm/test/CodeGen/ARM/vpadd.ll @@ -495,6 +495,15 @@ define <2 x i8> @fromExtendingExtractVectorElt_2i8(<8 x i8> %in) { ret <2 x i8> %x } +define <2 x i16> @fromExtendingExtractVectorElt_2i16(<8 x i16> %in) { +; CHECK-LABEL: fromExtendingExtractVectorElt_2i16: +; CHECK: vadd.i32 + %tmp1 = shufflevector <8 x i16> %in, <8 x i16> undef, <2 x i32> + %tmp2 = shufflevector <8 x i16> %in, <8 x i16> undef, <2 x i32> + %x = add <2 x i16> %tmp2, %tmp1 + ret <2 x i16> %x +} + declare <4 x i16> @llvm.arm.neon.vpaddls.v4i16.v8i8(<8 x i8>) nounwind readnone declare <2 x i32> @llvm.arm.neon.vpaddls.v2i32.v4i16(<4 x i16>) nounwind readnone