Skip to content

Commit aea4528

Browse files
committed
[RISCV] Improve cost model test coverage for insert/extract element
In particular, high LMULs, constant offsets within high LMUL, and types which require splitting. Note that most of these are way off with current lowering.
1 parent 967d953 commit aea4528

File tree

2 files changed

+192
-8
lines changed

2 files changed

+192
-8
lines changed

llvm/test/Analysis/CostModel/RISCV/rvv-extractelement.ll

Lines changed: 96 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2-
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv32 -mattr=+v,+f,+d,+zfh,+zvfh -riscv-v-vector-bits-min=-1 < %s | FileCheck %s --check-prefixes=RV32V
3-
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv64 -mattr=+v,+f,+d,+zfh,+zvfh -riscv-v-vector-bits-min=-1 < %s | FileCheck %s --check-prefixes=RV64V
4-
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv32 -mattr=+zve64x -riscv-v-vector-bits-min=-1 < %s | FileCheck %s --check-prefixes=RV32ZVE64X
5-
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv64 -mattr=+zve64x -riscv-v-vector-bits-min=-1 < %s | FileCheck %s --check-prefixes=RV64ZVE64X
2+
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv32 -mattr=+v,+f,+d,+zfh,+zvfh < %s | FileCheck %s --check-prefixes=RV32V
3+
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv64 -mattr=+v,+f,+d,+zfh,+zvfh < %s | FileCheck %s --check-prefixes=RV64V
4+
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv32 -mattr=+zve64x < %s | FileCheck %s --check-prefixes=RV32ZVE64X
5+
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv64 -mattr=+zve64x < %s | FileCheck %s --check-prefixes=RV64ZVE64X
66
; Check that we don't crash querying costs when vectors are not enabled.
77
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv64
88

@@ -862,6 +862,98 @@ define void @extractelement_int(i32 %x) {
862862
ret void
863863
}
864864

865+
; Cover high lmul extracts and types which require splitting
866+
define void @extractelement_int_lmul(i32 %x) {
867+
; RV32V-LABEL: 'extractelement_int_lmul'
868+
; RV32V-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v128i8_31 = extractelement <128 x i8> undef, i32 31
869+
; RV32V-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v128i8_63 = extractelement <128 x i8> undef, i32 63
870+
; RV32V-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v128i8_127 = extractelement <128 x i8> undef, i32 127
871+
; RV32V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v256i8_127 = extractelement <256 x i8> undef, i32 127
872+
; RV32V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v256i8_255 = extractelement <256 x i8> undef, i32 255
873+
; RV32V-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v32i32_3 = extractelement <32 x i32> undef, i32 3
874+
; RV32V-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v32i32_7 = extractelement <32 x i32> undef, i32 7
875+
; RV32V-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v32i32_15 = extractelement <32 x i32> undef, i32 15
876+
; RV32V-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v32i32_31 = extractelement <32 x i32> undef, i32 31
877+
; RV32V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v64i32_63 = extractelement <64 x i32> undef, i32 63
878+
; RV32V-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v128i8 = extractelement <128 x i8> undef, i32 %x
879+
; RV32V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v256i8 = extractelement <256 x i8> undef, i32 %x
880+
; RV32V-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v32i32 = extractelement <32 x i32> undef, i32 %x
881+
; RV32V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v64i32 = extractelement <64 x i32> undef, i32 %x
882+
; RV32V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret void
883+
;
884+
; RV64V-LABEL: 'extractelement_int_lmul'
885+
; RV64V-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v128i8_31 = extractelement <128 x i8> undef, i32 31
886+
; RV64V-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v128i8_63 = extractelement <128 x i8> undef, i32 63
887+
; RV64V-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v128i8_127 = extractelement <128 x i8> undef, i32 127
888+
; RV64V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v256i8_127 = extractelement <256 x i8> undef, i32 127
889+
; RV64V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v256i8_255 = extractelement <256 x i8> undef, i32 255
890+
; RV64V-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v32i32_3 = extractelement <32 x i32> undef, i32 3
891+
; RV64V-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v32i32_7 = extractelement <32 x i32> undef, i32 7
892+
; RV64V-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v32i32_15 = extractelement <32 x i32> undef, i32 15
893+
; RV64V-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v32i32_31 = extractelement <32 x i32> undef, i32 31
894+
; RV64V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v64i32_63 = extractelement <64 x i32> undef, i32 63
895+
; RV64V-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v128i8 = extractelement <128 x i8> undef, i32 %x
896+
; RV64V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v256i8 = extractelement <256 x i8> undef, i32 %x
897+
; RV64V-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v32i32 = extractelement <32 x i32> undef, i32 %x
898+
; RV64V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v64i32 = extractelement <64 x i32> undef, i32 %x
899+
; RV64V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret void
900+
;
901+
; RV32ZVE64X-LABEL: 'extractelement_int_lmul'
902+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v128i8_31 = extractelement <128 x i8> undef, i32 31
903+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v128i8_63 = extractelement <128 x i8> undef, i32 63
904+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v128i8_127 = extractelement <128 x i8> undef, i32 127
905+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v256i8_127 = extractelement <256 x i8> undef, i32 127
906+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v256i8_255 = extractelement <256 x i8> undef, i32 255
907+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v32i32_3 = extractelement <32 x i32> undef, i32 3
908+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v32i32_7 = extractelement <32 x i32> undef, i32 7
909+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v32i32_15 = extractelement <32 x i32> undef, i32 15
910+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v32i32_31 = extractelement <32 x i32> undef, i32 31
911+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v64i32_63 = extractelement <64 x i32> undef, i32 63
912+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v128i8 = extractelement <128 x i8> undef, i32 %x
913+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v256i8 = extractelement <256 x i8> undef, i32 %x
914+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v32i32 = extractelement <32 x i32> undef, i32 %x
915+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v64i32 = extractelement <64 x i32> undef, i32 %x
916+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret void
917+
;
918+
; RV64ZVE64X-LABEL: 'extractelement_int_lmul'
919+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v128i8_31 = extractelement <128 x i8> undef, i32 31
920+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v128i8_63 = extractelement <128 x i8> undef, i32 63
921+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v128i8_127 = extractelement <128 x i8> undef, i32 127
922+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v256i8_127 = extractelement <256 x i8> undef, i32 127
923+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v256i8_255 = extractelement <256 x i8> undef, i32 255
924+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v32i32_3 = extractelement <32 x i32> undef, i32 3
925+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v32i32_7 = extractelement <32 x i32> undef, i32 7
926+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v32i32_15 = extractelement <32 x i32> undef, i32 15
927+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v32i32_31 = extractelement <32 x i32> undef, i32 31
928+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v64i32_63 = extractelement <64 x i32> undef, i32 63
929+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v128i8 = extractelement <128 x i8> undef, i32 %x
930+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v256i8 = extractelement <256 x i8> undef, i32 %x
931+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v32i32 = extractelement <32 x i32> undef, i32 %x
932+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v64i32 = extractelement <64 x i32> undef, i32 %x
933+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret void
934+
;
935+
%v128i8_31 = extractelement <128 x i8> undef, i32 31
936+
%v128i8_63 = extractelement <128 x i8> undef, i32 63
937+
%v128i8_127 = extractelement <128 x i8> undef, i32 127
938+
%v256i8_127 = extractelement <256 x i8> undef, i32 127
939+
%v256i8_255 = extractelement <256 x i8> undef, i32 255
940+
941+
%v32i32_3 = extractelement <32 x i32> undef, i32 3
942+
%v32i32_7 = extractelement <32 x i32> undef, i32 7
943+
%v32i32_15 = extractelement <32 x i32> undef, i32 15
944+
%v32i32_31 = extractelement <32 x i32> undef, i32 31
945+
%v64i32_63 = extractelement <64 x i32> undef, i32 63
946+
947+
948+
%v128i8 = extractelement <128 x i8> undef, i32 %x
949+
%v256i8 = extractelement <256 x i8> undef, i32 %x
950+
951+
%v32i32 = extractelement <32 x i32> undef, i32 %x
952+
%v64i32 = extractelement <64 x i32> undef, i32 %x
953+
954+
ret void
955+
}
956+
865957
define void @extractelement_fp(i32 %x) {
866958
; RV32V-LABEL: 'extractelement_fp'
867959
; RV32V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v2f16_0 = extractelement <2 x half> undef, i32 0

0 commit comments

Comments
 (0)