diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -2165,9 +2165,10 @@ case Intrinsic::aarch64_neon_uaddlv: { MVT VT = Op.getOperand(1).getValueType().getSimpleVT(); unsigned BitWidth = Known.getBitWidth(); - if (VT == MVT::v8i8) { - assert(BitWidth >= 16 && "Unexpected width!"); - APInt Mask = APInt::getHighBitsSet(BitWidth, BitWidth - 16); + if (VT == MVT::v8i8 || VT == MVT::v16i8) { + unsigned Bound = (VT == MVT::v8i8) ? 11 : 12; + assert(BitWidth >= Bound && "Unexpected width!"); + APInt Mask = APInt::getHighBitsSet(BitWidth, BitWidth - Bound); Known.Zero |= Mask; } break; diff --git a/llvm/test/CodeGen/AArch64/aarch64-neon-vector-insert-uaddlv.ll b/llvm/test/CodeGen/AArch64/aarch64-neon-vector-insert-uaddlv.ll --- a/llvm/test/CodeGen/AArch64/aarch64-neon-vector-insert-uaddlv.ll +++ b/llvm/test/CodeGen/AArch64/aarch64-neon-vector-insert-uaddlv.ll @@ -300,7 +300,7 @@ ; CHECK-NEXT: stp xzr, xzr, [x0, #16] ; CHECK-NEXT: uaddlv.8b h1, v0 ; CHECK-NEXT: mov.h v0[0], v1[0] -; CHECK-NEXT: bic.4h v0, #255, lsl #8 +; CHECK-NEXT: bic.4h v0, #7, lsl #8 ; CHECK-NEXT: ushll.4s v0, v0, #0 ; CHECK-NEXT: ucvtf.4s v0, v0 ; CHECK-NEXT: str q0, [x0] diff --git a/llvm/test/CodeGen/AArch64/neon-addlv.ll b/llvm/test/CodeGen/AArch64/neon-addlv.ll --- a/llvm/test/CodeGen/AArch64/neon-addlv.ll +++ b/llvm/test/CodeGen/AArch64/neon-addlv.ll @@ -153,8 +153,8 @@ declare i32 @llvm.aarch64.neon.uaddlv.i32.v8i8(<8 x i8>) nounwind readnone -define i32 @uaddlv_known_bits(<8 x i8> %a) { -; CHECK-LABEL: uaddlv_known_bits: +define i32 @uaddlv_known_bits_v8i8(<8 x i8> %a) { +; CHECK-LABEL: uaddlv_known_bits_v8i8: ; CHECK: // %bb.0: ; CHECK-NEXT: uaddlv h0, v0.8b ; CHECK-NEXT: fmov w0, s0 @@ -163,3 +163,17 @@ %tmp2 = and i32 %tmp1, 65535 ret i32 %tmp2 } + +declare i32 @llvm.aarch64.neon.uaddlv.i32.v16i8(<16 x i8>) nounwind readnone + +define i32 @uaddlv_known_bits_v16i8(<16 x i8> %a) { +; CHECK-LABEL: uaddlv_known_bits_v16i8: +; CHECK: // %bb.0: // %entry +; CHECK-NEXT: uaddlv h0, v0.16b +; CHECK-NEXT: fmov w0, s0 +; CHECK-NEXT: ret +entry: + %vaddlv.i = tail call i32 @llvm.aarch64.neon.uaddlv.i32.v16i8(<16 x i8> %a) + %0 = and i32 %vaddlv.i, 65535 + ret i32 %0 +}