Skip to content

Commit c43190f

Browse files
committed
[RISCV] Add cost model coverage for insert/extract element w/ 2^N - 1 types
We currently return costs which are too low for these.
1 parent e03669a commit c43190f

File tree

2 files changed

+118
-0
lines changed

2 files changed

+118
-0
lines changed

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

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,3 +1437,67 @@ define void @extractelement_fp(i32 %x) {
14371437

14381438
ret void
14391439
}
1440+
1441+
1442+
define void @extractelement_int_nonpoweroftwo(i32 %x) {
1443+
; RV32V-LABEL: 'extractelement_int_nonpoweroftwo'
1444+
; RV32V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v3i8 = extractelement <3 x i8> undef, i32 %x
1445+
; RV32V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v7i8 = extractelement <7 x i8> undef, i32 %x
1446+
; RV32V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v15i8 = extractelement <15 x i8> undef, i32 %x
1447+
; RV32V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v31i8 = extractelement <31 x i8> undef, i32 %x
1448+
; RV32V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v3i32 = extractelement <3 x i32> undef, i32 %x
1449+
; RV32V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v7i32 = extractelement <7 x i32> undef, i32 %x
1450+
; RV32V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v15i32 = extractelement <15 x i32> undef, i32 %x
1451+
; RV32V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v31i32 = extractelement <31 x i32> undef, i32 %x
1452+
; RV32V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v31i32_0 = extractelement <31 x i32> undef, i32 0
1453+
; RV32V-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
1454+
;
1455+
; RV64V-LABEL: 'extractelement_int_nonpoweroftwo'
1456+
; RV64V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v3i8 = extractelement <3 x i8> undef, i32 %x
1457+
; RV64V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v7i8 = extractelement <7 x i8> undef, i32 %x
1458+
; RV64V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v15i8 = extractelement <15 x i8> undef, i32 %x
1459+
; RV64V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v31i8 = extractelement <31 x i8> undef, i32 %x
1460+
; RV64V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v3i32 = extractelement <3 x i32> undef, i32 %x
1461+
; RV64V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v7i32 = extractelement <7 x i32> undef, i32 %x
1462+
; RV64V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v15i32 = extractelement <15 x i32> undef, i32 %x
1463+
; RV64V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v31i32 = extractelement <31 x i32> undef, i32 %x
1464+
; RV64V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v31i32_0 = extractelement <31 x i32> undef, i32 0
1465+
; RV64V-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
1466+
;
1467+
; RV32ZVE64X-LABEL: 'extractelement_int_nonpoweroftwo'
1468+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v3i8 = extractelement <3 x i8> undef, i32 %x
1469+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v7i8 = extractelement <7 x i8> undef, i32 %x
1470+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v15i8 = extractelement <15 x i8> undef, i32 %x
1471+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v31i8 = extractelement <31 x i8> undef, i32 %x
1472+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v3i32 = extractelement <3 x i32> undef, i32 %x
1473+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v7i32 = extractelement <7 x i32> undef, i32 %x
1474+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v15i32 = extractelement <15 x i32> undef, i32 %x
1475+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v31i32 = extractelement <31 x i32> undef, i32 %x
1476+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v31i32_0 = extractelement <31 x i32> undef, i32 0
1477+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
1478+
;
1479+
; RV64ZVE64X-LABEL: 'extractelement_int_nonpoweroftwo'
1480+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v3i8 = extractelement <3 x i8> undef, i32 %x
1481+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v7i8 = extractelement <7 x i8> undef, i32 %x
1482+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v15i8 = extractelement <15 x i8> undef, i32 %x
1483+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v31i8 = extractelement <31 x i8> undef, i32 %x
1484+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v3i32 = extractelement <3 x i32> undef, i32 %x
1485+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v7i32 = extractelement <7 x i32> undef, i32 %x
1486+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v15i32 = extractelement <15 x i32> undef, i32 %x
1487+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v31i32 = extractelement <31 x i32> undef, i32 %x
1488+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v31i32_0 = extractelement <31 x i32> undef, i32 0
1489+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
1490+
;
1491+
%v3i8 = extractelement <3 x i8> undef, i32 %x
1492+
%v7i8 = extractelement <7 x i8> undef, i32 %x
1493+
%v15i8 = extractelement <15 x i8> undef, i32 %x
1494+
%v31i8 = extractelement <31 x i8> undef, i32 %x
1495+
1496+
%v3i32 = extractelement <3 x i32> undef, i32 %x
1497+
%v7i32 = extractelement <7 x i32> undef, i32 %x
1498+
%v15i32 = extractelement <15 x i32> undef, i32 %x
1499+
%v31i32 = extractelement <31 x i32> undef, i32 %x
1500+
%v31i32_0 = extractelement <31 x i32> undef, i32 0
1501+
1502+
ret void
1503+
}

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

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,3 +1437,57 @@ define void @insertelement_fp(i32 %x) {
14371437

14381438
ret void
14391439
}
1440+
1441+
1442+
define void @insertelement_int_nonpoweroftwo(i32 %x) {
1443+
; RV32V-LABEL: 'insertelement_int_nonpoweroftwo'
1444+
; RV32V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v3i8 = insertelement <3 x i8> undef, i8 undef, i32 %x
1445+
; RV32V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v7i8 = insertelement <7 x i8> undef, i8 undef, i32 %x
1446+
; RV32V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v15i8 = insertelement <15 x i8> undef, i8 undef, i32 %x
1447+
; RV32V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v3i32_0 = insertelement <3 x i32> undef, i32 undef, i32 0
1448+
; RV32V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v3i32 = insertelement <3 x i32> undef, i32 undef, i32 %x
1449+
; RV32V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v7i32 = insertelement <7 x i32> undef, i32 undef, i32 %x
1450+
; RV32V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v15i32 = insertelement <15 x i32> undef, i32 undef, i32 %x
1451+
; RV32V-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
1452+
;
1453+
; RV64V-LABEL: 'insertelement_int_nonpoweroftwo'
1454+
; RV64V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v3i8 = insertelement <3 x i8> undef, i8 undef, i32 %x
1455+
; RV64V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v7i8 = insertelement <7 x i8> undef, i8 undef, i32 %x
1456+
; RV64V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v15i8 = insertelement <15 x i8> undef, i8 undef, i32 %x
1457+
; RV64V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v3i32_0 = insertelement <3 x i32> undef, i32 undef, i32 0
1458+
; RV64V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v3i32 = insertelement <3 x i32> undef, i32 undef, i32 %x
1459+
; RV64V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v7i32 = insertelement <7 x i32> undef, i32 undef, i32 %x
1460+
; RV64V-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v15i32 = insertelement <15 x i32> undef, i32 undef, i32 %x
1461+
; RV64V-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
1462+
;
1463+
; RV32ZVE64X-LABEL: 'insertelement_int_nonpoweroftwo'
1464+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v3i8 = insertelement <3 x i8> undef, i8 undef, i32 %x
1465+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v7i8 = insertelement <7 x i8> undef, i8 undef, i32 %x
1466+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v15i8 = insertelement <15 x i8> undef, i8 undef, i32 %x
1467+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v3i32_0 = insertelement <3 x i32> undef, i32 undef, i32 0
1468+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v3i32 = insertelement <3 x i32> undef, i32 undef, i32 %x
1469+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v7i32 = insertelement <7 x i32> undef, i32 undef, i32 %x
1470+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v15i32 = insertelement <15 x i32> undef, i32 undef, i32 %x
1471+
; RV32ZVE64X-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
1472+
;
1473+
; RV64ZVE64X-LABEL: 'insertelement_int_nonpoweroftwo'
1474+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v3i8 = insertelement <3 x i8> undef, i8 undef, i32 %x
1475+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v7i8 = insertelement <7 x i8> undef, i8 undef, i32 %x
1476+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v15i8 = insertelement <15 x i8> undef, i8 undef, i32 %x
1477+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v3i32_0 = insertelement <3 x i32> undef, i32 undef, i32 0
1478+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v3i32 = insertelement <3 x i32> undef, i32 undef, i32 %x
1479+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v7i32 = insertelement <7 x i32> undef, i32 undef, i32 %x
1480+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v15i32 = insertelement <15 x i32> undef, i32 undef, i32 %x
1481+
; RV64ZVE64X-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
1482+
;
1483+
%v3i8 = insertelement <3 x i8> undef, i8 undef, i32 %x
1484+
%v7i8 = insertelement <7 x i8> undef, i8 undef, i32 %x
1485+
%v15i8 = insertelement <15 x i8> undef, i8 undef, i32 %x
1486+
1487+
%v3i32_0 = insertelement <3 x i32> undef, i32 undef, i32 0
1488+
%v3i32 = insertelement <3 x i32> undef, i32 undef, i32 %x
1489+
%v7i32 = insertelement <7 x i32> undef, i32 undef, i32 %x
1490+
%v15i32 = insertelement <15 x i32> undef, i32 undef, i32 %x
1491+
1492+
ret void
1493+
}

0 commit comments

Comments
 (0)