diff --git a/llvm/include/llvm/CodeGen/ValueTypes.h b/llvm/include/llvm/CodeGen/ValueTypes.h --- a/llvm/include/llvm/CodeGen/ValueTypes.h +++ b/llvm/include/llvm/CodeGen/ValueTypes.h @@ -298,6 +298,7 @@ } /// Given a vector type, return the number of elements it contains. + /// This assumes a fixed-vector type unsigned getVectorNumElements() const { #ifdef STRICT_FIXED_SIZE_VECTORS assert(isFixedLengthVector() && "Invalid vector type!"); @@ -323,7 +324,8 @@ return getExtendedVectorElementCount(); } - /// Given a vector type, return the minimum number of elements it contains. + /// Given a (possibly scalable) vector type, + /// return the minimum number of elements it contains. unsigned getVectorMinNumElements() const { return getVectorElementCount().getKnownMinValue(); } 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 @@ -15112,7 +15112,7 @@ } } - if (N0.getOpcode() != ISD::SETCC || CCVT.getVectorNumElements() != 1 || + if (N0.getOpcode() != ISD::SETCC || CCVT.getVectorMinNumElements() != 1 || CCVT.getVectorElementType() != MVT::i1) return SDValue(); diff --git a/llvm/test/CodeGen/AArch64/vselect-sve-interface-warnings.ll b/llvm/test/CodeGen/AArch64/vselect-sve-interface-warnings.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/vselect-sve-interface-warnings.ll @@ -0,0 +1,61 @@ +; RUN: llc -mtriple=aarch64-linux-unknown -mattr=+sve -o /dev/null < %s 2>&1 | FileCheck %s --implicit-check-not "warning" --allow-empty + +define @vselect_cmp_ne( %a, %b, %c) { + %cmp = icmp ne %a, %b + %d = select %cmp, %b, %c + ret %d +} + +define @vselect_cmp_eq( %a, %b, %c) { + %cmp = icmp eq %a, %b + %d = select %cmp, %b, %c + ret %d +} + +define @vselect_cmp_sgt( %a, %b, %c) { + %cmp = icmp sgt %a, %b + %d = select %cmp, %b, %c + ret %d +} + +define @vselect_cmp_sge( %a, %b, %c) { + %cmp = icmp sge %a, %b + %d = select %cmp, %b, %c + ret %d +} + +define @vselect_cmp_slt( %a, %b, %c) { + %cmp = icmp slt %a, %b + %d = select %cmp, %b, %c + ret %d +} + +define @vselect_cmp_sle( %a, %b, %c) { + %cmp = icmp sle %a, %b + %d = select %cmp, %b, %c + ret %d +} + +define @vselect_cmp_ugt( %a, %b, %c) { + %cmp = icmp ugt %a, %b + %d = select %cmp, %b, %c + ret %d +} + +define @vselect_cmp_uge( %a, %b, %c) { + %cmp = icmp uge %a, %b + %d = select %cmp, %b, %c + ret %d +} + +define @vselect_cmp_ult( %a, %b, %c) { + %cmp = icmp ult %a, %b + %d = select %cmp, %b, %c + ret %d +} + +define @vselect_cmp_ule( %a, %b, %c) { + %cmp = icmp ule %a, %b + %d = select %cmp, %b, %c + ret %d +}