[llvm] c43190f - [RISCV] Add cost model coverage for insert/extract element w/ 2^N - 1 types

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 28 11:40:44 PDT 2024


Author: Philip Reames
Date: 2024-08-28T11:40:32-07:00
New Revision: c43190f99445b1b76d06b650247d72fc109b5d4b

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

LOG: [RISCV] Add cost model coverage for insert/extract element w/ 2^N - 1 types

We currently return costs which are too low for these.

Added: 
    

Modified: 
    llvm/test/Analysis/CostModel/RISCV/rvv-extractelement.ll
    llvm/test/Analysis/CostModel/RISCV/rvv-insertelement.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Analysis/CostModel/RISCV/rvv-extractelement.ll b/llvm/test/Analysis/CostModel/RISCV/rvv-extractelement.ll
index aa7a90bece3390..c9145784afcc1c 100644
--- a/llvm/test/Analysis/CostModel/RISCV/rvv-extractelement.ll
+++ b/llvm/test/Analysis/CostModel/RISCV/rvv-extractelement.ll
@@ -1437,3 +1437,67 @@ define void @extractelement_fp(i32 %x) {
 
   ret void
 }
+
+
+define void @extractelement_int_nonpoweroftwo(i32 %x) {
+; RV32V-LABEL: 'extractelement_int_nonpoweroftwo'
+; RV32V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v3i8 = extractelement <3 x i8> undef, i32 %x
+; RV32V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v7i8 = extractelement <7 x i8> undef, i32 %x
+; RV32V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v15i8 = extractelement <15 x i8> undef, i32 %x
+; RV32V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v31i8 = extractelement <31 x i8> undef, i32 %x
+; RV32V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v3i32 = extractelement <3 x i32> undef, i32 %x
+; RV32V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v7i32 = extractelement <7 x i32> undef, i32 %x
+; RV32V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v15i32 = extractelement <15 x i32> undef, i32 %x
+; RV32V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v31i32 = extractelement <31 x i32> undef, i32 %x
+; RV32V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v31i32_0 = extractelement <31 x i32> undef, i32 0
+; RV32V-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret void
+;
+; RV64V-LABEL: 'extractelement_int_nonpoweroftwo'
+; RV64V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v3i8 = extractelement <3 x i8> undef, i32 %x
+; RV64V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v7i8 = extractelement <7 x i8> undef, i32 %x
+; RV64V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v15i8 = extractelement <15 x i8> undef, i32 %x
+; RV64V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v31i8 = extractelement <31 x i8> undef, i32 %x
+; RV64V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v3i32 = extractelement <3 x i32> undef, i32 %x
+; RV64V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v7i32 = extractelement <7 x i32> undef, i32 %x
+; RV64V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v15i32 = extractelement <15 x i32> undef, i32 %x
+; RV64V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v31i32 = extractelement <31 x i32> undef, i32 %x
+; RV64V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v31i32_0 = extractelement <31 x i32> undef, i32 0
+; RV64V-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret void
+;
+; RV32ZVE64X-LABEL: 'extractelement_int_nonpoweroftwo'
+; RV32ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v3i8 = extractelement <3 x i8> undef, i32 %x
+; RV32ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v7i8 = extractelement <7 x i8> undef, i32 %x
+; RV32ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v15i8 = extractelement <15 x i8> undef, i32 %x
+; RV32ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v31i8 = extractelement <31 x i8> undef, i32 %x
+; RV32ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v3i32 = extractelement <3 x i32> undef, i32 %x
+; RV32ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v7i32 = extractelement <7 x i32> undef, i32 %x
+; RV32ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v15i32 = extractelement <15 x i32> undef, i32 %x
+; RV32ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v31i32 = extractelement <31 x i32> undef, i32 %x
+; RV32ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v31i32_0 = extractelement <31 x i32> undef, i32 0
+; RV32ZVE64X-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret void
+;
+; RV64ZVE64X-LABEL: 'extractelement_int_nonpoweroftwo'
+; RV64ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v3i8 = extractelement <3 x i8> undef, i32 %x
+; RV64ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v7i8 = extractelement <7 x i8> undef, i32 %x
+; RV64ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v15i8 = extractelement <15 x i8> undef, i32 %x
+; RV64ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v31i8 = extractelement <31 x i8> undef, i32 %x
+; RV64ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v3i32 = extractelement <3 x i32> undef, i32 %x
+; RV64ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v7i32 = extractelement <7 x i32> undef, i32 %x
+; RV64ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v15i32 = extractelement <15 x i32> undef, i32 %x
+; RV64ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v31i32 = extractelement <31 x i32> undef, i32 %x
+; RV64ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v31i32_0 = extractelement <31 x i32> undef, i32 0
+; RV64ZVE64X-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret void
+;
+  %v3i8 = extractelement <3 x i8> undef, i32 %x
+  %v7i8 = extractelement <7 x i8> undef, i32 %x
+  %v15i8 = extractelement <15 x i8> undef, i32 %x
+  %v31i8 = extractelement <31 x i8> undef, i32 %x
+
+  %v3i32 = extractelement <3 x i32> undef, i32 %x
+  %v7i32 = extractelement <7 x i32> undef, i32 %x
+  %v15i32 = extractelement <15 x i32> undef, i32 %x
+  %v31i32 = extractelement <31 x i32> undef, i32 %x
+  %v31i32_0 = extractelement <31 x i32> undef, i32 0
+
+  ret void
+}

diff  --git a/llvm/test/Analysis/CostModel/RISCV/rvv-insertelement.ll b/llvm/test/Analysis/CostModel/RISCV/rvv-insertelement.ll
index 8b68480788f79e..c167adf1f33977 100644
--- a/llvm/test/Analysis/CostModel/RISCV/rvv-insertelement.ll
+++ b/llvm/test/Analysis/CostModel/RISCV/rvv-insertelement.ll
@@ -1437,3 +1437,57 @@ define void @insertelement_fp(i32 %x) {
 
   ret void
 }
+
+
+define void @insertelement_int_nonpoweroftwo(i32 %x) {
+; RV32V-LABEL: 'insertelement_int_nonpoweroftwo'
+; RV32V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v3i8 = insertelement <3 x i8> undef, i8 undef, i32 %x
+; RV32V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v7i8 = insertelement <7 x i8> undef, i8 undef, i32 %x
+; RV32V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v15i8 = insertelement <15 x i8> undef, i8 undef, i32 %x
+; RV32V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v3i32_0 = insertelement <3 x i32> undef, i32 undef, i32 0
+; RV32V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v3i32 = insertelement <3 x i32> undef, i32 undef, i32 %x
+; RV32V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v7i32 = insertelement <7 x i32> undef, i32 undef, i32 %x
+; RV32V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v15i32 = insertelement <15 x i32> undef, i32 undef, i32 %x
+; RV32V-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret void
+;
+; RV64V-LABEL: 'insertelement_int_nonpoweroftwo'
+; RV64V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v3i8 = insertelement <3 x i8> undef, i8 undef, i32 %x
+; RV64V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v7i8 = insertelement <7 x i8> undef, i8 undef, i32 %x
+; RV64V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v15i8 = insertelement <15 x i8> undef, i8 undef, i32 %x
+; RV64V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v3i32_0 = insertelement <3 x i32> undef, i32 undef, i32 0
+; RV64V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v3i32 = insertelement <3 x i32> undef, i32 undef, i32 %x
+; RV64V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v7i32 = insertelement <7 x i32> undef, i32 undef, i32 %x
+; RV64V-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v15i32 = insertelement <15 x i32> undef, i32 undef, i32 %x
+; RV64V-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret void
+;
+; RV32ZVE64X-LABEL: 'insertelement_int_nonpoweroftwo'
+; RV32ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v3i8 = insertelement <3 x i8> undef, i8 undef, i32 %x
+; RV32ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v7i8 = insertelement <7 x i8> undef, i8 undef, i32 %x
+; RV32ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v15i8 = insertelement <15 x i8> undef, i8 undef, i32 %x
+; RV32ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v3i32_0 = insertelement <3 x i32> undef, i32 undef, i32 0
+; RV32ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v3i32 = insertelement <3 x i32> undef, i32 undef, i32 %x
+; RV32ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v7i32 = insertelement <7 x i32> undef, i32 undef, i32 %x
+; RV32ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v15i32 = insertelement <15 x i32> undef, i32 undef, i32 %x
+; RV32ZVE64X-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret void
+;
+; RV64ZVE64X-LABEL: 'insertelement_int_nonpoweroftwo'
+; RV64ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v3i8 = insertelement <3 x i8> undef, i8 undef, i32 %x
+; RV64ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v7i8 = insertelement <7 x i8> undef, i8 undef, i32 %x
+; RV64ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v15i8 = insertelement <15 x i8> undef, i8 undef, i32 %x
+; RV64ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v3i32_0 = insertelement <3 x i32> undef, i32 undef, i32 0
+; RV64ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v3i32 = insertelement <3 x i32> undef, i32 undef, i32 %x
+; RV64ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v7i32 = insertelement <7 x i32> undef, i32 undef, i32 %x
+; RV64ZVE64X-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v15i32 = insertelement <15 x i32> undef, i32 undef, i32 %x
+; RV64ZVE64X-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret void
+;
+  %v3i8 = insertelement <3 x i8> undef, i8 undef, i32 %x
+  %v7i8 = insertelement <7 x i8> undef, i8 undef, i32 %x
+  %v15i8 = insertelement <15 x i8> undef, i8 undef, i32 %x
+
+  %v3i32_0 = insertelement <3 x i32> undef, i32 undef, i32 0
+  %v3i32 = insertelement <3 x i32> undef, i32 undef, i32 %x
+  %v7i32 = insertelement <7 x i32> undef, i32 undef, i32 %x
+  %v15i32 = insertelement <15 x i32> undef, i32 undef, i32 %x
+
+  ret void
+}


        


More information about the llvm-commits mailing list