[llvm] 4d31348 - [RISCV] Add vector fabs intrinsic costs

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 24 14:10:10 PDT 2022


Author: Philip Reames
Date: 2022-08-24T14:09:51-07:00
New Revision: 4d3134866fb32cf3d792dfda879148e122afb326

URL: https://github.com/llvm/llvm-project/commit/4d3134866fb32cf3d792dfda879148e122afb326
DIFF: https://github.com/llvm/llvm-project/commit/4d3134866fb32cf3d792dfda879148e122afb326.diff

LOG: [RISCV] Add vector fabs intrinsic costs

We have a fabs vector instruction, and are using it for current lowering.

Added: 
    

Modified: 
    llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
    llvm/test/Analysis/CostModel/RISCV/trig-log-exp.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
index cc5b55b231c8c..53b9ba39b7d89 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -321,6 +321,22 @@ static const CostTblEntry VectorIntrinsicCostTable[]{
    {Intrinsic::round, MVT::nxv2f64, 10},
    {Intrinsic::round, MVT::nxv4f64, 10},
    {Intrinsic::round, MVT::nxv8f64, 10},
+   {Intrinsic::fabs, MVT::v2f32, 1},
+   {Intrinsic::fabs, MVT::v4f32, 1},
+   {Intrinsic::fabs, MVT::v8f32, 1},
+   {Intrinsic::fabs, MVT::v16f32, 1},
+   {Intrinsic::fabs, MVT::nxv2f32, 1},
+   {Intrinsic::fabs, MVT::nxv4f32, 1},
+   {Intrinsic::fabs, MVT::nxv8f32, 1},
+   {Intrinsic::fabs, MVT::nxv16f32, 1},
+   {Intrinsic::fabs, MVT::v2f64, 1},
+   {Intrinsic::fabs, MVT::v4f64, 1},
+   {Intrinsic::fabs, MVT::v8f64, 1},
+   {Intrinsic::fabs, MVT::v16f64, 1},
+   {Intrinsic::fabs, MVT::nxv1f64, 1},
+   {Intrinsic::fabs, MVT::nxv2f64, 1},
+   {Intrinsic::fabs, MVT::nxv4f64, 1},
+   {Intrinsic::fabs, MVT::nxv8f64, 1},
 };
 
 InstructionCost

diff  --git a/llvm/test/Analysis/CostModel/RISCV/trig-log-exp.ll b/llvm/test/Analysis/CostModel/RISCV/trig-log-exp.ll
index 46c0122a0894f..21a9bf1900ac8 100644
--- a/llvm/test/Analysis/CostModel/RISCV/trig-log-exp.ll
+++ b/llvm/test/Analysis/CostModel/RISCV/trig-log-exp.ll
@@ -305,19 +305,19 @@ define void @log2() {
 define void @fabs() {
 ; CHECK-LABEL: 'fabs'
 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %1 = call float @llvm.fabs.f32(float undef)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %2 = call <2 x float> @llvm.fabs.v2f32(<2 x float> undef)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %3 = call <4 x float> @llvm.fabs.v4f32(<4 x float> undef)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %4 = call <8 x float> @llvm.fabs.v8f32(<8 x float> undef)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %5 = call <16 x float> @llvm.fabs.v16f32(<16 x float> undef)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %2 = call <2 x float> @llvm.fabs.v2f32(<2 x float> undef)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %3 = call <4 x float> @llvm.fabs.v4f32(<4 x float> undef)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %4 = call <8 x float> @llvm.fabs.v8f32(<8 x float> undef)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %5 = call <16 x float> @llvm.fabs.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.fabs.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.fabs.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.fabs.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.fabs.nxv16f32(<vscale x 16 x float> undef)
 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %10 = call double @llvm.fabs.f64(double undef)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %11 = call <2 x double> @llvm.fabs.v2f64(<2 x double> undef)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %12 = call <4 x double> @llvm.fabs.v4f64(<4 x double> undef)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %13 = call <8 x double> @llvm.fabs.v8f64(<8 x double> undef)
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %14 = call <16 x double> @llvm.fabs.v16f64(<16 x double> undef)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %11 = call <2 x double> @llvm.fabs.v2f64(<2 x double> undef)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %12 = call <4 x double> @llvm.fabs.v4f64(<4 x double> undef)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %13 = call <8 x double> @llvm.fabs.v8f64(<8 x double> undef)
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %14 = call <16 x double> @llvm.fabs.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.fabs.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.fabs.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.fabs.nxv4f64(<vscale x 4 x double> undef)


        


More information about the llvm-commits mailing list