diff --git a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp index 33c6555cc710e2..3e0f419ca3f940 100644 --- a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp @@ -3253,6 +3253,8 @@ InstructionCost AArch64TTIImpl::getShuffleCost(TTI::ShuffleKind Kind, {TTI::SK_Broadcast, MVT::v2i32, 1}, {TTI::SK_Broadcast, MVT::v4i32, 1}, {TTI::SK_Broadcast, MVT::v2i64, 1}, + {TTI::SK_Broadcast, MVT::v4f16, 1}, + {TTI::SK_Broadcast, MVT::v8f16, 1}, {TTI::SK_Broadcast, MVT::v2f32, 1}, {TTI::SK_Broadcast, MVT::v4f32, 1}, {TTI::SK_Broadcast, MVT::v2f64, 1}, @@ -3265,6 +3267,8 @@ InstructionCost AArch64TTIImpl::getShuffleCost(TTI::ShuffleKind Kind, {TTI::SK_Transpose, MVT::v2i32, 1}, {TTI::SK_Transpose, MVT::v4i32, 1}, {TTI::SK_Transpose, MVT::v2i64, 1}, + {TTI::SK_Transpose, MVT::v4f16, 1}, + {TTI::SK_Transpose, MVT::v8f16, 1}, {TTI::SK_Transpose, MVT::v2f32, 1}, {TTI::SK_Transpose, MVT::v4f32, 1}, {TTI::SK_Transpose, MVT::v2f64, 1}, diff --git a/llvm/test/Analysis/CostModel/AArch64/shuffle-load.ll b/llvm/test/Analysis/CostModel/AArch64/shuffle-load.ll index 52e392b5044027..b048f0e86be19e 100644 --- a/llvm/test/Analysis/CostModel/AArch64/shuffle-load.ll +++ b/llvm/test/Analysis/CostModel/AArch64/shuffle-load.ll @@ -38,13 +38,13 @@ define void @shuffle() { ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %lv4i64 = load <4 x i64>, ptr undef, align 32 ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %sv4i64 = shufflevector <4 x i64> %lv4i64, <4 x i64> undef, <4 x i32> zeroinitializer ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %lv2f16 = load <2 x half>, ptr undef, align 4 -; CHECK-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %sv2f16 = shufflevector <2 x half> %lv2f16, <2 x half> undef, <2 x i32> zeroinitializer +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %sv2f16 = shufflevector <2 x half> %lv2f16, <2 x half> undef, <2 x i32> zeroinitializer ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %lv4f16 = load <4 x half>, ptr undef, align 8 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %sv4f16 = shufflevector <4 x half> %lv4f16, <4 x half> undef, <4 x i32> zeroinitializer ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %lv8f16 = load <8 x half>, ptr undef, align 16 -; CHECK-NEXT: Cost Model: Found an estimated cost of 21 for instruction: %sv8f16 = shufflevector <8 x half> %lv8f16, <8 x half> undef, <8 x i32> zeroinitializer +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %sv8f16 = shufflevector <8 x half> %lv8f16, <8 x half> undef, <8 x i32> zeroinitializer ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %lv16f16 = load <16 x half>, ptr undef, align 32 -; CHECK-NEXT: Cost Model: Found an estimated cost of 42 for instruction: %sv16f16 = shufflevector <16 x half> %lv16f16, <16 x half> undef, <16 x i32> zeroinitializer +; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %sv16f16 = shufflevector <16 x half> %lv16f16, <16 x half> undef, <16 x i32> zeroinitializer ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %lv2f32 = load <2 x float>, ptr undef, align 8 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %sv2f32 = shufflevector <2 x float> %lv2f32, <2 x float> undef, <2 x i32> zeroinitializer ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %lv4f32 = load <4 x float>, ptr undef, align 16 @@ -184,13 +184,13 @@ define <8 x half> @ld1r_8h_float_shuff(ptr nocapture %x) { ; CHECK-LABEL: 'ld1r_8h_float_shuff' ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %tmp = load half, ptr %x, align 2 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %tmp1 = insertelement <8 x half> undef, half %tmp, i32 0 -; CHECK-NEXT: Cost Model: Found an estimated cost of 21 for instruction: %lane = shufflevector <8 x half> %tmp1, <8 x half> undef, <8 x i32> zeroinitializer +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %lane = shufflevector <8 x half> %tmp1, <8 x half> undef, <8 x i32> zeroinitializer ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <8 x half> %lane ; ; CODESIZE-LABEL: 'ld1r_8h_float_shuff' ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %tmp = load half, ptr %x, align 2 ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %tmp1 = insertelement <8 x half> undef, half %tmp, i32 0 -; CODESIZE-NEXT: Cost Model: Found an estimated cost of 21 for instruction: %lane = shufflevector <8 x half> %tmp1, <8 x half> undef, <8 x i32> zeroinitializer +; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %lane = shufflevector <8 x half> %tmp1, <8 x half> undef, <8 x i32> zeroinitializer ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret <8 x half> %lane ; entry: diff --git a/llvm/test/Analysis/CostModel/AArch64/shuffle-transpose.ll b/llvm/test/Analysis/CostModel/AArch64/shuffle-transpose.ll index 8ed09368b3fa4e..6680f70aafe4d8 100644 --- a/llvm/test/Analysis/CostModel/AArch64/shuffle-transpose.ll +++ b/llvm/test/Analysis/CostModel/AArch64/shuffle-transpose.ll @@ -182,3 +182,39 @@ define <2 x double> @trn2.v2f64(<2 x double> %v0, <2 x double> %v1) { %tmp0 = shufflevector <2 x double> %v0, <2 x double> %v1, <2 x i32> ret <2 x double> %tmp0 } + +; COST-LABEL: trn1.v4f16 +; COST: Found an estimated cost of 1 for instruction: %tmp0 = shufflevector <4 x half> %v0, <4 x half> %v1, <4 x i32> +; CODE-LABEL: trn1.v4f16 +; CODE: trn1 v0.4h, v0.4h, v1.4h +define <4 x half> @trn1.v4f16(<4 x half> %v0, <4 x half> %v1) { + %tmp0 = shufflevector <4 x half> %v0, <4 x half> %v1, <4 x i32> + ret <4 x half> %tmp0 +} + +; COST-LABEL: trn2.v4f16 +; COST: Found an estimated cost of 1 for instruction: %tmp0 = shufflevector <4 x half> %v0, <4 x half> %v1, <4 x i32> +; CODE-LABEL: trn2.v4f16 +; CODE: trn2 v0.4h, v0.4h, v1.4h +define <4 x half> @trn2.v4f16(<4 x half> %v0, <4 x half> %v1) { + %tmp0 = shufflevector <4 x half> %v0, <4 x half> %v1, <4 x i32> + ret <4 x half> %tmp0 +} + +; COST-LABEL: trn1.v8f16 +; COST: Found an estimated cost of 1 for instruction: %tmp0 = shufflevector <8 x half> %v0, <8 x half> %v1, <8 x i32> +; CODE-LABEL: trn1.v8f16 +; CODE: trn1 v0.8h, v0.8h, v1.8h +define <8 x half> @trn1.v8f16(<8 x half> %v0, <8 x half> %v1) { + %tmp0 = shufflevector <8 x half> %v0, <8 x half> %v1, <8 x i32> + ret <8 x half> %tmp0 +} + +; COST-LABEL: trn2.v8f16 +; COST: Found an estimated cost of 1 for instruction: %tmp0 = shufflevector <8 x half> %v0, <8 x half> %v1, <8 x i32> +; CODE-LABEL: trn2.v8f16 +; CODE: trn2 v0.8h, v0.8h, v1.8h +define <8 x half> @trn2.v8f16(<8 x half> %v0, <8 x half> %v1) { + %tmp0 = shufflevector <8 x half> %v0, <8 x half> %v1, <8 x i32> + ret <8 x half> %tmp0 +}