diff --git a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp --- a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp @@ -240,8 +240,8 @@ // A helper that returns a vector type from the given type. The number of // elements in type Ty determine the vector width. auto toVectorTy = [&](Type *ArgTy) { - return FixedVectorType::get(ArgTy->getScalarType(), - cast(DstTy)->getNumElements()); + return VectorType::get(ArgTy->getScalarType(), + cast(DstTy)->getElementCount()); }; // Exit early if DstTy is not a vector type whose elements are at least @@ -290,8 +290,8 @@ return false; // Get the total number of vector elements in the legalized types. - unsigned NumDstEls = DstTyL.first * DstTyL.second.getVectorNumElements(); - unsigned NumSrcEls = SrcTyL.first * SrcTyL.second.getVectorNumElements(); + unsigned NumDstEls = DstTyL.first * DstTyL.second.getVectorMinNumElements(); + unsigned NumSrcEls = SrcTyL.first * SrcTyL.second.getVectorMinNumElements(); // Return true if the legalized types have the same number of vector elements // and the destination element type size is twice that of the source type. diff --git a/llvm/test/Analysis/CostModel/AArch64/sve-widening-instruction.ll b/llvm/test/Analysis/CostModel/AArch64/sve-widening-instruction.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Analysis/CostModel/AArch64/sve-widening-instruction.ll @@ -0,0 +1,21 @@ +; Checks if widening instructions works for SVE + +; RUN: opt -cost-model -analyze -mtriple=aarch64--linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s +; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t + +; If this check fails please read test/CodeGen/AArch64/README for instructions on how to resolve it. +; WARN-NOT: warning + +define @widening( %in, %in2) { + +; CHECK-LABEL: 'widening': +; CHECK: Cost Model: Found an estimated cost of {{[0-9]+}} for instruction: %in.bc = bitcast %in to +; CHECK-NEXT: Cost Model: Found an estimated cost of {{[0-9]+}} for instruction: %in2.ext = zext %in2 to +; CHECK-NEXT: Cost Model: Found an estimated cost of {{[0-9]+}} for instruction: %in.add = add %in.bc, %in2.ext +; CHECK-NEXT: Cost Model: Found an estimated cost of {{[0-9]+}} for instruction: ret %in.add + + %in.bc = bitcast %in to + %in2.ext = zext %in2 to + %in.add = add %in.bc, %in2.ext + ret %in.add +}