From 9199b6535df17c719c980beb3883c956f9d5f809 Mon Sep 17 00:00:00 2001 From: Caroline Concatto Date: Thu, 13 May 2021 19:06:55 +0100 Subject: [PATCH] [CostModel][AArch64] Add missing costs for getShuffleCost with scalable vectors Differential Revision: https://reviews.llvm.org/D102490 --- .../Target/AArch64/AArch64TargetTransformInfo.cpp | 14 ++++++ .../Analysis/CostModel/AArch64/sve-intrinsics.ll | 25 ++++++++++- .../CostModel/AArch64/sve-shuffle-broadcast.ll | 50 +++++++++++++++------- 3 files changed, 71 insertions(+), 18 deletions(-) diff --git a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp index 1293d45..9076205 100644 --- a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp @@ -1678,17 +1678,31 @@ InstructionCost AArch64TTIImpl::getShuffleCost(TTI::ShuffleKind Kind, { TTI::SK_Broadcast, MVT::nxv8i16, 1 }, { TTI::SK_Broadcast, MVT::nxv4i32, 1 }, { TTI::SK_Broadcast, MVT::nxv2i64, 1 }, + { TTI::SK_Broadcast, MVT::nxv2f16, 1 }, + { TTI::SK_Broadcast, MVT::nxv4f16, 1 }, { TTI::SK_Broadcast, MVT::nxv8f16, 1 }, + { TTI::SK_Broadcast, MVT::nxv2bf16, 1 }, + { TTI::SK_Broadcast, MVT::nxv4bf16, 1 }, { TTI::SK_Broadcast, MVT::nxv8bf16, 1 }, + { TTI::SK_Broadcast, MVT::nxv2f32, 1 }, { TTI::SK_Broadcast, MVT::nxv4f32, 1 }, { TTI::SK_Broadcast, MVT::nxv2f64, 1 }, + { TTI::SK_Broadcast, MVT::nxv16i1, 1 }, + { TTI::SK_Broadcast, MVT::nxv8i1, 1 }, + { TTI::SK_Broadcast, MVT::nxv4i1, 1 }, + { TTI::SK_Broadcast, MVT::nxv2i1, 1 }, // Handle the cases for vector.reverse with scalable vectors { TTI::SK_Reverse, MVT::nxv16i8, 1 }, { TTI::SK_Reverse, MVT::nxv8i16, 1 }, { TTI::SK_Reverse, MVT::nxv4i32, 1 }, { TTI::SK_Reverse, MVT::nxv2i64, 1 }, + { TTI::SK_Reverse, MVT::nxv2f16, 1 }, + { TTI::SK_Reverse, MVT::nxv4f16, 1 }, { TTI::SK_Reverse, MVT::nxv8f16, 1 }, + { TTI::SK_Reverse, MVT::nxv2bf16, 1 }, + { TTI::SK_Reverse, MVT::nxv4bf16, 1 }, { TTI::SK_Reverse, MVT::nxv8bf16, 1 }, + { TTI::SK_Reverse, MVT::nxv2f32, 1 }, { TTI::SK_Reverse, MVT::nxv4f32, 1 }, { TTI::SK_Reverse, MVT::nxv2f64, 1 }, { TTI::SK_Reverse, MVT::nxv16i1, 1 }, diff --git a/llvm/test/Analysis/CostModel/AArch64/sve-intrinsics.ll b/llvm/test/Analysis/CostModel/AArch64/sve-intrinsics.ll index f0c11e2..1877b19 100644 --- a/llvm/test/Analysis/CostModel/AArch64/sve-intrinsics.ll +++ b/llvm/test/Analysis/CostModel/AArch64/sve-intrinsics.ll @@ -114,18 +114,25 @@ define void @vector_reverse() #0 { ; CHECK-LABEL: 'vector_reverse': ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %reverse_nxv16i8 = call @llvm.experimental.vector.reverse.nxv16i8( undef) ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %reverse_nxv32i8 = call @llvm.experimental.vector.reverse.nxv32i8( undef) +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %reverse_nxv2i16 = call @llvm.experimental.vector.reverse.nxv2i16( undef) +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %reverse_nxv4i16 = call @llvm.experimental.vector.reverse.nxv4i16( undef) ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %reverse_nxv8i16 = call @llvm.experimental.vector.reverse.nxv8i16( undef) ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %reverse_nxv16i16 = call @llvm.experimental.vector.reverse.nxv16i16( undef) ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %reverse_nxv4i32 = call @llvm.experimental.vector.reverse.nxv4i32( undef) ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %reverse_nxv8i32 = call @llvm.experimental.vector.reverse.nxv8i32( undef) ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %reverse_nxv2i64 = call @llvm.experimental.vector.reverse.nxv2i64( undef) ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %reverse_nxv4i64 = call @llvm.experimental.vector.reverse.nxv4i64( undef) -; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %reverse_nxv8if16 = call @llvm.experimental.vector.reverse.nxv8f16( undef) +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %reverse_nxv2f16 = call @llvm.experimental.vector.reverse.nxv2f16( undef) +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %reverse_nxv4f16 = call @llvm.experimental.vector.reverse.nxv4f16( undef) +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %reverse_nxv8f16 = call @llvm.experimental.vector.reverse.nxv8f16( undef) ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %reverse_nxv16f16 = call @llvm.experimental.vector.reverse.nxv16f16( undef) +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %reverse_nxv2f32 = call @llvm.experimental.vector.reverse.nxv2f32( undef) ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %reverse_nxv4f32 = call @llvm.experimental.vector.reverse.nxv4f32( undef) ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %reverse_nxv8f32 = call @llvm.experimental.vector.reverse.nxv8f32( undef) ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %reverse_nxv2f64 = call @llvm.experimental.vector.reverse.nxv2f64( undef) ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %reverse_nxv4f64 = call @llvm.experimental.vector.reverse.nxv4f64( undef) +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %reverse_nxv2bf16 = call @llvm.experimental.vector.reverse.nxv2bf16( undef) +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %reverse_nxv4bf16 = call @llvm.experimental.vector.reverse.nxv4bf16( undef) ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %reverse_nxv8bf16 = call @llvm.experimental.vector.reverse.nxv8bf16( undef) ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %reverse_nxv16bf16 = call @llvm.experimental.vector.reverse.nxv16bf16( undef) ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %reverse_nxv16i1 = call @llvm.experimental.vector.reverse.nxv16i1( undef) @@ -135,18 +142,25 @@ define void @vector_reverse() #0 { %reverse_nxv16i8 = call @llvm.experimental.vector.reverse.nxv16i8( undef) %reverse_nxv32i8 = call @llvm.experimental.vector.reverse.nxv32i8( undef) + %reverse_nxv2i16 = call @llvm.experimental.vector.reverse.nxv2i16( undef) + %reverse_nxv4i16 = call @llvm.experimental.vector.reverse.nxv4i16( undef) %reverse_nxv8i16 = call @llvm.experimental.vector.reverse.nxv8i16( undef) %reverse_nxv16i16 = call @llvm.experimental.vector.reverse.nxv16i16( undef) %reverse_nxv4i32 = call @llvm.experimental.vector.reverse.nxv4i32( undef) %reverse_nxv8i32 = call @llvm.experimental.vector.reverse.nxv8i32( undef) %reverse_nxv2i64 = call @llvm.experimental.vector.reverse.nxv2i64( undef) %reverse_nxv4i64 = call @llvm.experimental.vector.reverse.nxv4i64( undef) - %reverse_nxv8if16 = call @llvm.experimental.vector.reverse.nxv8f16( undef) + %reverse_nxv2f16 = call @llvm.experimental.vector.reverse.nxv2f16( undef) + %reverse_nxv4f16 = call @llvm.experimental.vector.reverse.nxv4f16( undef) + %reverse_nxv8f16 = call @llvm.experimental.vector.reverse.nxv8f16( undef) %reverse_nxv16f16 = call @llvm.experimental.vector.reverse.nxv16f16( undef) + %reverse_nxv2f32 = call @llvm.experimental.vector.reverse.nxv2f32( undef) %reverse_nxv4f32 = call @llvm.experimental.vector.reverse.nxv4f32( undef) %reverse_nxv8f32 = call @llvm.experimental.vector.reverse.nxv8f32( undef) %reverse_nxv2f64 = call @llvm.experimental.vector.reverse.nxv2f64( undef) %reverse_nxv4f64 = call @llvm.experimental.vector.reverse.nxv4f64( undef) + %reverse_nxv2bf16 = call @llvm.experimental.vector.reverse.nxv2bf16( undef) + %reverse_nxv4bf16 = call @llvm.experimental.vector.reverse.nxv4bf16( undef) %reverse_nxv8bf16 = call @llvm.experimental.vector.reverse.nxv8bf16( undef) %reverse_nxv16bf16 = call @llvm.experimental.vector.reverse.nxv16bf16( undef) %reverse_nxv16i1 = call @llvm.experimental.vector.reverse.nxv16i1( undef) @@ -157,18 +171,25 @@ define void @vector_reverse() #0 { } declare @llvm.experimental.vector.reverse.nxv16i8() declare @llvm.experimental.vector.reverse.nxv32i8() +declare @llvm.experimental.vector.reverse.nxv2i16() +declare @llvm.experimental.vector.reverse.nxv4i16() declare @llvm.experimental.vector.reverse.nxv8i16() declare @llvm.experimental.vector.reverse.nxv16i16() declare @llvm.experimental.vector.reverse.nxv4i32() declare @llvm.experimental.vector.reverse.nxv8i32() declare @llvm.experimental.vector.reverse.nxv2i64() declare @llvm.experimental.vector.reverse.nxv4i64() +declare @llvm.experimental.vector.reverse.nxv2f16() +declare @llvm.experimental.vector.reverse.nxv4f16() declare @llvm.experimental.vector.reverse.nxv8f16() declare @llvm.experimental.vector.reverse.nxv16f16() +declare @llvm.experimental.vector.reverse.nxv2f32() declare @llvm.experimental.vector.reverse.nxv4f32() declare @llvm.experimental.vector.reverse.nxv8f32() declare @llvm.experimental.vector.reverse.nxv2f64() declare @llvm.experimental.vector.reverse.nxv4f64() +declare @llvm.experimental.vector.reverse.nxv2bf16() +declare @llvm.experimental.vector.reverse.nxv4bf16() declare @llvm.experimental.vector.reverse.nxv8bf16() declare @llvm.experimental.vector.reverse.nxv16bf16() declare @llvm.experimental.vector.reverse.nxv16i1() diff --git a/llvm/test/Analysis/CostModel/AArch64/sve-shuffle-broadcast.ll b/llvm/test/Analysis/CostModel/AArch64/sve-shuffle-broadcast.ll index e94cbb2..25f7177 100644 --- a/llvm/test/Analysis/CostModel/AArch64/sve-shuffle-broadcast.ll +++ b/llvm/test/Analysis/CostModel/AArch64/sve-shuffle-broadcast.ll @@ -12,14 +12,23 @@ define void @broadcast() #0{ ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %5 = shufflevector undef, undef, zeroinitializer ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %6 = shufflevector undef, undef, zeroinitializer ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %7 = shufflevector undef, undef, zeroinitializer -; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %8 = shufflevector undef, undef, zeroinitializer -; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %9 = shufflevector undef, undef, zeroinitializer -; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %10 = shufflevector undef, undef, zeroinitializer -; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %11 = shufflevector undef, undef, zeroinitializer -; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %12 = shufflevector undef, undef, zeroinitializer -; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %13 = shufflevector undef, undef, zeroinitializer -; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %14 = shufflevector undef, undef, zeroinitializer -; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %15 = shufflevector undef, undef, zeroinitializer +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %8 = shufflevector undef, undef, zeroinitializer +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %9 = shufflevector undef, undef, zeroinitializer +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %10 = shufflevector undef, undef, zeroinitializer +; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %11 = shufflevector undef, undef, zeroinitializer +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %12 = shufflevector undef, undef, zeroinitializer +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %13 = shufflevector undef, undef, zeroinitializer +; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %14 = shufflevector undef, undef, zeroinitializer +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %15 = shufflevector undef, undef, zeroinitializer +; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %16 = shufflevector undef, undef, zeroinitializer +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %17 = shufflevector undef, undef, zeroinitializer +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %18 = shufflevector undef, undef, zeroinitializer +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %19 = shufflevector undef, undef, zeroinitializer +; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %20 = shufflevector undef, undef, zeroinitializer +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %21 = shufflevector undef, undef, zeroinitializer +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %22 = shufflevector undef, undef, zeroinitializer +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %23 = shufflevector undef, undef, zeroinitializer +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %24 = shufflevector undef, undef, zeroinitializer ; CHECK-NETX: Cost Model: Found an estimated cost of 0 for instruction: ret void %zero = shufflevector undef, undef, zeroinitializer @@ -30,14 +39,23 @@ define void @broadcast() #0{ %5 = shufflevector undef, undef, zeroinitializer %6 = shufflevector undef, undef, zeroinitializer %7 = shufflevector undef, undef, zeroinitializer - %8 = shufflevector undef, undef, zeroinitializer - %9 = shufflevector undef, undef, zeroinitializer - %10 = shufflevector undef, undef, zeroinitializer - %11 = shufflevector undef, undef, zeroinitializer - %12 = shufflevector undef, undef, zeroinitializer - %13 = shufflevector undef, undef, zeroinitializer - %14 = shufflevector undef, undef, zeroinitializer - %15 = shufflevector undef, undef, zeroinitializer + %8 = shufflevector undef, undef, zeroinitializer + %9 = shufflevector undef, undef, zeroinitializer + %10 = shufflevector undef, undef, zeroinitializer + %11 = shufflevector undef, undef, zeroinitializer + %12 = shufflevector undef, undef, zeroinitializer + %13 = shufflevector undef, undef, zeroinitializer + %14 = shufflevector undef, undef, zeroinitializer + %15 = shufflevector undef, undef, zeroinitializer + %16 = shufflevector undef, undef, zeroinitializer + %17 = shufflevector undef, undef, zeroinitializer + %18 = shufflevector undef, undef, zeroinitializer + %19 = shufflevector undef, undef, zeroinitializer + %20 = shufflevector undef, undef, zeroinitializer + %21 = shufflevector undef, undef, zeroinitializer + %22 = shufflevector undef, undef, zeroinitializer + %23 = shufflevector undef, undef, zeroinitializer + %24 = shufflevector undef, undef, zeroinitializer ret void } -- 2.7.4