[RISCV] Add empirically measured vector sqrt intrinsic costs
authorPhilip Reames <preames@rivosinc.com>
Wed, 24 Aug 2022 21:21:43 +0000 (14:21 -0700)
committerPhilip Reames <listmail@philipreames.com>
Wed, 24 Aug 2022 21:27:57 +0000 (14:27 -0700)
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
llvm/test/Analysis/CostModel/RISCV/sqrt.ll

index 53b9ba3..446a081 100644 (file)
@@ -337,6 +337,22 @@ static const CostTblEntry VectorIntrinsicCostTable[]{
    {Intrinsic::fabs, MVT::nxv2f64, 1},
    {Intrinsic::fabs, MVT::nxv4f64, 1},
    {Intrinsic::fabs, MVT::nxv8f64, 1},
+   {Intrinsic::sqrt, MVT::v2f32, 1},
+   {Intrinsic::sqrt, MVT::v4f32, 1},
+   {Intrinsic::sqrt, MVT::v8f32, 1},
+   {Intrinsic::sqrt, MVT::v16f32, 1},
+   {Intrinsic::sqrt, MVT::nxv2f32, 1},
+   {Intrinsic::sqrt, MVT::nxv4f32, 1},
+   {Intrinsic::sqrt, MVT::nxv8f32, 1},
+   {Intrinsic::sqrt, MVT::nxv16f32, 1},
+   {Intrinsic::sqrt, MVT::v2f64, 1},
+   {Intrinsic::sqrt, MVT::v4f64, 1},
+   {Intrinsic::sqrt, MVT::v8f64, 1},
+   {Intrinsic::sqrt, MVT::v16f64, 1},
+   {Intrinsic::sqrt, MVT::nxv1f64, 1},
+   {Intrinsic::sqrt, MVT::nxv2f64, 1},
+   {Intrinsic::sqrt, MVT::nxv4f64, 1},
+   {Intrinsic::sqrt, MVT::nxv8f64, 1},
 };
 
 InstructionCost
index 9722910..e5c3ab5 100644 (file)
@@ -4,19 +4,19 @@
 define void @sqrt() {
 ; CHECK-LABEL: 'sqrt'
 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %1 = call float @llvm.sqrt.f32(float undef)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %2 = call <2 x float> @llvm.sqrt.v2f32(<2 x float> undef)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %3 = call <4 x float> @llvm.sqrt.v4f32(<4 x float> undef)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %4 = call <8 x float> @llvm.sqrt.v8f32(<8 x float> undef)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %5 = call <16 x float> @llvm.sqrt.v16f32(<16 x float> undef)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %2 = call <2 x float> @llvm.sqrt.v2f32(<2 x float> undef)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %3 = call <4 x float> @llvm.sqrt.v4f32(<4 x float> undef)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %4 = call <8 x float> @llvm.sqrt.v8f32(<8 x float> undef)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %5 = call <16 x float> @llvm.sqrt.v16f32(<16 x float> undef)
 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %6 = call <vscale x 2 x float> @llvm.sqrt.nxv2f32(<vscale x 2 x float> undef)
 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %7 = call <vscale x 4 x float> @llvm.sqrt.nxv4f32(<vscale x 4 x float> undef)
 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %8 = call <vscale x 8 x float> @llvm.sqrt.nxv8f32(<vscale x 8 x float> undef)
 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %9 = call <vscale x 16 x float> @llvm.sqrt.nxv16f32(<vscale x 16 x float> undef)
 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %10 = call double @llvm.sqrt.f64(double undef)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %11 = call <2 x double> @llvm.sqrt.v2f64(<2 x double> undef)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %12 = call <4 x double> @llvm.sqrt.v4f64(<4 x double> undef)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %13 = call <8 x double> @llvm.sqrt.v8f64(<8 x double> undef)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %14 = call <16 x double> @llvm.sqrt.v16f64(<16 x double> undef)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %11 = call <2 x double> @llvm.sqrt.v2f64(<2 x double> undef)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %12 = call <4 x double> @llvm.sqrt.v4f64(<4 x double> undef)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %13 = call <8 x double> @llvm.sqrt.v8f64(<8 x double> undef)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %14 = call <16 x double> @llvm.sqrt.v16f64(<16 x double> undef)
 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %15 = call <vscale x 1 x double> @llvm.sqrt.nxv1f64(<vscale x 1 x double> undef)
 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %16 = call <vscale x 2 x double> @llvm.sqrt.nxv2f64(<vscale x 2 x double> undef)
 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %17 = call <vscale x 4 x double> @llvm.sqrt.nxv4f64(<vscale x 4 x double> undef)