-
Notifications
You must be signed in to change notification settings - Fork 14.1k
[RISCV][TTI] Discount slide cost if ri.vinsert/ri.vextract are available #142036
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RISCV][TTI] Discount slide cost if ri.vinsert/ri.vextract are available #142036
Conversation
If we have the ri.vinsert/vextract instructions from xrivosvisni, we can do an element insert or extract without needing a vslide or a vector temporary register. Adjust the TTI cost to reflect this.
@llvm/pr-subscribers-backend-risc-v Author: Philip Reames (preames) ChangesIf we have the ri.vinsert/vextract instructions from xrivosvisni, we can do an element insert or extract without needing a vslide or a vector temporary register. Adjust the TTI cost to reflect this. Patch is 84.26 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/142036.diff 3 Files Affected:
diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
index 860d787111ce4..ff822dec232a9 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -2297,9 +2297,12 @@ InstructionCost RISCVTTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
Index = Index % M1Max;
}
- // We could extract/insert the first element without vslidedown/vslideup.
if (Index == 0)
+ // We can extract/insert the first element without vslidedown/vslideup.
SlideCost = 0;
+ else if (ST->hasVendorXRivosVisni() && isUInt<5>(Index) &&
+ Val->getScalarType()->isIntegerTy())
+ SlideCost = 0; // With ri.vinsert/ri.vextract there is no slide needed
else if (Opcode == Instruction::InsertElement)
SlideCost = 1; // With a constant index, we do not need to use addi.
}
diff --git a/llvm/test/Analysis/CostModel/RISCV/rvv-extractelement.ll b/llvm/test/Analysis/CostModel/RISCV/rvv-extractelement.ll
index 2859d9fa15168..bca1624d279e7 100644
--- a/llvm/test/Analysis/CostModel/RISCV/rvv-extractelement.ll
+++ b/llvm/test/Analysis/CostModel/RISCV/rvv-extractelement.ll
@@ -1,6 +1,7 @@
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv32 -mattr=+v,+f,+d,+zfh,+zvfh < %s | FileCheck %s --check-prefixes=RV32V
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv64 -mattr=+v,+f,+d,+zfh,+zvfh < %s | FileCheck %s --check-prefixes=RV64V
+; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv64 -mattr=+v,+f,+d,+zfh,+zvfh,+experimental-xrivosvisni < %s | FileCheck %s --check-prefixes=VISNI
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv32 -mattr=+zve64x < %s | FileCheck %s --check-prefixes=RV32ZVE64X
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv64 -mattr=+zve64x < %s | FileCheck %s --check-prefixes=RV64ZVE64X
; Check that we don't crash querying costs when vectors are not enabled.
@@ -337,6 +338,171 @@ define void @extractelement_int(i32 %x) {
; RV64V-NEXT: Cost Model: Found an estimated cost of 18 for instruction: %nxv16i64_x = extractelement <vscale x 16 x i64> undef, i32 %x
; RV64V-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
;
+; VISNI-LABEL: 'extractelement_int'
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %v2i1_0 = extractelement <2 x i1> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %v4i1_0 = extractelement <4 x i1> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %v8i1_0 = extractelement <8 x i1> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %v16i1_0 = extractelement <16 x i1> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 5 for instruction: %v32i1_0 = extractelement <32 x i1> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %nxv2i1_0 = extractelement <vscale x 2 x i1> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %nxv4i1_0 = extractelement <vscale x 4 x i1> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %nxv8i1_0 = extractelement <vscale x 8 x i1> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 5 for instruction: %nxv16i1_0 = extractelement <vscale x 16 x i1> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 9 for instruction: %nxv32i1_0 = extractelement <vscale x 32 x i1> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v2i8_0 = extractelement <2 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v4i8_0 = extractelement <4 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v8i8_0 = extractelement <8 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v16i8_0 = extractelement <16 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v32i8_0 = extractelement <32 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v64i8_0 = extractelement <64 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v128i8_0 = extractelement <128 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv2i8_0 = extractelement <vscale x 2 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv4i8_0 = extractelement <vscale x 4 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv8i8_0 = extractelement <vscale x 8 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv16i8_0 = extractelement <vscale x 16 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv32i8_0 = extractelement <vscale x 32 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv64i8_0 = extractelement <vscale x 64 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv128i8_0 = extractelement <vscale x 128 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v2i16_0 = extractelement <2 x i16> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v4i16_0 = extractelement <4 x i16> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v8i16_0 = extractelement <8 x i16> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v16i16_0 = extractelement <16 x i16> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v32i16_0 = extractelement <32 x i16> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v64i16_0 = extractelement <64 x i16> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv2i16_0 = extractelement <vscale x 2 x i16> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv4i16_0 = extractelement <vscale x 4 x i16> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv8i16_0 = extractelement <vscale x 8 x i16> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv16i16_0 = extractelement <vscale x 16 x i16> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv32i16_0 = extractelement <vscale x 32 x i16> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv64i16_0 = extractelement <vscale x 64 x i16> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v2i32_0 = extractelement <2 x i32> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v4i32_0 = extractelement <4 x i32> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v8i32_0 = extractelement <8 x i32> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v16i32_0 = extractelement <16 x i32> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v32i32_0 = extractelement <32 x i32> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv2i32_0 = extractelement <vscale x 2 x i32> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv4i32_0 = extractelement <vscale x 4 x i32> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv8i32_0 = extractelement <vscale x 8 x i32> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv16i32_0 = extractelement <vscale x 16 x i32> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv32i32_0 = extractelement <vscale x 32 x i32> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v2i64_0 = extractelement <2 x i64> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v4i64_0 = extractelement <4 x i64> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v8i64_0 = extractelement <8 x i64> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v16i64_0 = extractelement <16 x i64> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv2i64_0 = extractelement <vscale x 2 x i64> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv4i64_0 = extractelement <vscale x 4 x i64> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv8i64_0 = extractelement <vscale x 8 x i64> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv16i64_0 = extractelement <vscale x 16 x i64> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %v2i1_1 = extractelement <2 x i1> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %v4i1_1 = extractelement <4 x i1> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %v8i1_1 = extractelement <8 x i1> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %v16i1_1 = extractelement <16 x i1> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 5 for instruction: %v32i1_1 = extractelement <32 x i1> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %nxv2i1_1 = extractelement <vscale x 2 x i1> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %nxv4i1_1 = extractelement <vscale x 4 x i1> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %nxv8i1_1 = extractelement <vscale x 8 x i1> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 5 for instruction: %nxv16i1_1 = extractelement <vscale x 16 x i1> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 9 for instruction: %nxv32i1_1 = extractelement <vscale x 32 x i1> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v2i8_1 = extractelement <2 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v4i8_1 = extractelement <4 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v8i8_1 = extractelement <8 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v16i8_1 = extractelement <16 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v32i8_1 = extractelement <32 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v64i8_1 = extractelement <64 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v128i8_1 = extractelement <128 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv2i8_1 = extractelement <vscale x 2 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv4i8_1 = extractelement <vscale x 4 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv8i8_1 = extractelement <vscale x 8 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv16i8_1 = extractelement <vscale x 16 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv32i8_1 = extractelement <vscale x 32 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv64i8_1 = extractelement <vscale x 64 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv128i8_1 = extractelement <vscale x 128 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v2i16_1 = extractelement <2 x i16> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v4i16_1 = extractelement <4 x i16> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v8i16_1 = extractelement <8 x i16> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v16i16_1 = extractelement <16 x i16> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v32i16_1 = extractelement <32 x i16> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v64i16_1 = extractelement <64 x i16> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv2i16_1 = extractelement <vscale x 2 x i16> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv4i16_1 = extractelement <vscale x 4 x i16> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv8i16_1 = extractelement <vscale x 8 x i16> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv16i16_1 = extractelement <vscale x 16 x i16> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv32i16_1 = extractelement <vscale x 32 x i16> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv64i16_1 = extractelement <vscale x 64 x i16> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v2i32_1 = extractelement <2 x i32> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v4i32_1 = extractelement <4 x i32> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v8i32_1 = extractelement <8 x i32> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v16i32_1 = extractelement <16 x i32> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v32i32_1 = extractelement <32 x i32> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv2i32_1 = extractelement <vscale x 2 x i32> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv4i32_1 = extractelement <vscale x 4 x i32> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv8i32_1 = extractelement <vscale x 8 x i32> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv16i32_1 = extractelement <vscale x 16 x i32> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv32i32_1 = extractelement <vscale x 32 x i32> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v2i64_1 = extractelement <2 x i64> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v4i64_1 = extractelement <4 x i64> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v8i64_1 = extractelement <8 x i64> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v16i64_1 = extractelement <16 x i64> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv2i64_1 = extractelement <vscale x 2 x i64> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv4i64_1 = extractelement <vscale x 4 x i64> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv8i64_1 = extractelement <vscale x 8 x i64> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv16i64_1 = extractelement <vscale x 16 x i64> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v2i1_x = extractelement <2 x i1> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v4i1_x = extractelement <4 x i1> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v8i1_x = extractelement <8 x i1> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v16i1_x = extractelement <16 x i1> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 6 for instruction: %v32i1_x = extractelement <32 x i1> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %nxv2i1_x = extractelement <vscale x 2 x i1> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %nxv4i1_x = extractelement <vscale x 4 x i1> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %nxv8i1_x = extractelement <vscale x 8 x i1> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 6 for instruction: %nxv16i1_x = extractelement <vscale x 16 x i1> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %nxv32i1_x = extractelement <vscale x 32 x i1> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v2i8_x = extractelement <2 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v4i8_x = extractelement <4 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v8i8_x = extractelement <8 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v16i8_x = extractelement <16 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v32i8_x = extractelement <32 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v64i8_x = extractelement <64 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v128i8_x = extractelement <128 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %nxv2i8_x = extractelement <vscale x 2 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %nxv4i8_x = extractelement <vscale x 4 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %nxv8i8_x = extractelement <vscale x 8 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %nxv16i8_x = extractelement <vscale x 16 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %nxv32i8_x = extractelement <vscale x 32 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %nxv64i8_x = extractelement <vscale x 64 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 18 for instruction: %nxv128i8_x = extractelement <vscale x 128 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v2i16_x = extractelement <2 x i16> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v4i16_x = extractelement <4 x i16> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v8i16_x = extractelement <8 x i16> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v16i16_x = extractelement <16 x i16> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v32i16_x = extractelement <32 x i16> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v64i16_x = extractelement <64 x i16> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %nxv2i16_x = extractelement <vscale x 2 x i16> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %nxv4i16_x = extractelement <vscale x 4 x i16> undef, i32 %...
[truncated]
|
@llvm/pr-subscribers-llvm-analysis Author: Philip Reames (preames) ChangesIf we have the ri.vinsert/vextract instructions from xrivosvisni, we can do an element insert or extract without needing a vslide or a vector temporary register. Adjust the TTI cost to reflect this. Patch is 84.26 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/142036.diff 3 Files Affected:
diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
index 860d787111ce4..ff822dec232a9 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -2297,9 +2297,12 @@ InstructionCost RISCVTTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
Index = Index % M1Max;
}
- // We could extract/insert the first element without vslidedown/vslideup.
if (Index == 0)
+ // We can extract/insert the first element without vslidedown/vslideup.
SlideCost = 0;
+ else if (ST->hasVendorXRivosVisni() && isUInt<5>(Index) &&
+ Val->getScalarType()->isIntegerTy())
+ SlideCost = 0; // With ri.vinsert/ri.vextract there is no slide needed
else if (Opcode == Instruction::InsertElement)
SlideCost = 1; // With a constant index, we do not need to use addi.
}
diff --git a/llvm/test/Analysis/CostModel/RISCV/rvv-extractelement.ll b/llvm/test/Analysis/CostModel/RISCV/rvv-extractelement.ll
index 2859d9fa15168..bca1624d279e7 100644
--- a/llvm/test/Analysis/CostModel/RISCV/rvv-extractelement.ll
+++ b/llvm/test/Analysis/CostModel/RISCV/rvv-extractelement.ll
@@ -1,6 +1,7 @@
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv32 -mattr=+v,+f,+d,+zfh,+zvfh < %s | FileCheck %s --check-prefixes=RV32V
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv64 -mattr=+v,+f,+d,+zfh,+zvfh < %s | FileCheck %s --check-prefixes=RV64V
+; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv64 -mattr=+v,+f,+d,+zfh,+zvfh,+experimental-xrivosvisni < %s | FileCheck %s --check-prefixes=VISNI
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv32 -mattr=+zve64x < %s | FileCheck %s --check-prefixes=RV32ZVE64X
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv64 -mattr=+zve64x < %s | FileCheck %s --check-prefixes=RV64ZVE64X
; Check that we don't crash querying costs when vectors are not enabled.
@@ -337,6 +338,171 @@ define void @extractelement_int(i32 %x) {
; RV64V-NEXT: Cost Model: Found an estimated cost of 18 for instruction: %nxv16i64_x = extractelement <vscale x 16 x i64> undef, i32 %x
; RV64V-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
;
+; VISNI-LABEL: 'extractelement_int'
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %v2i1_0 = extractelement <2 x i1> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %v4i1_0 = extractelement <4 x i1> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %v8i1_0 = extractelement <8 x i1> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %v16i1_0 = extractelement <16 x i1> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 5 for instruction: %v32i1_0 = extractelement <32 x i1> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %nxv2i1_0 = extractelement <vscale x 2 x i1> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %nxv4i1_0 = extractelement <vscale x 4 x i1> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %nxv8i1_0 = extractelement <vscale x 8 x i1> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 5 for instruction: %nxv16i1_0 = extractelement <vscale x 16 x i1> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 9 for instruction: %nxv32i1_0 = extractelement <vscale x 32 x i1> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v2i8_0 = extractelement <2 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v4i8_0 = extractelement <4 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v8i8_0 = extractelement <8 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v16i8_0 = extractelement <16 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v32i8_0 = extractelement <32 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v64i8_0 = extractelement <64 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v128i8_0 = extractelement <128 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv2i8_0 = extractelement <vscale x 2 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv4i8_0 = extractelement <vscale x 4 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv8i8_0 = extractelement <vscale x 8 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv16i8_0 = extractelement <vscale x 16 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv32i8_0 = extractelement <vscale x 32 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv64i8_0 = extractelement <vscale x 64 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv128i8_0 = extractelement <vscale x 128 x i8> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v2i16_0 = extractelement <2 x i16> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v4i16_0 = extractelement <4 x i16> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v8i16_0 = extractelement <8 x i16> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v16i16_0 = extractelement <16 x i16> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v32i16_0 = extractelement <32 x i16> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v64i16_0 = extractelement <64 x i16> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv2i16_0 = extractelement <vscale x 2 x i16> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv4i16_0 = extractelement <vscale x 4 x i16> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv8i16_0 = extractelement <vscale x 8 x i16> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv16i16_0 = extractelement <vscale x 16 x i16> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv32i16_0 = extractelement <vscale x 32 x i16> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv64i16_0 = extractelement <vscale x 64 x i16> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v2i32_0 = extractelement <2 x i32> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v4i32_0 = extractelement <4 x i32> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v8i32_0 = extractelement <8 x i32> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v16i32_0 = extractelement <16 x i32> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v32i32_0 = extractelement <32 x i32> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv2i32_0 = extractelement <vscale x 2 x i32> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv4i32_0 = extractelement <vscale x 4 x i32> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv8i32_0 = extractelement <vscale x 8 x i32> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv16i32_0 = extractelement <vscale x 16 x i32> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv32i32_0 = extractelement <vscale x 32 x i32> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v2i64_0 = extractelement <2 x i64> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v4i64_0 = extractelement <4 x i64> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v8i64_0 = extractelement <8 x i64> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v16i64_0 = extractelement <16 x i64> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv2i64_0 = extractelement <vscale x 2 x i64> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv4i64_0 = extractelement <vscale x 4 x i64> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv8i64_0 = extractelement <vscale x 8 x i64> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv16i64_0 = extractelement <vscale x 16 x i64> undef, i32 0
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %v2i1_1 = extractelement <2 x i1> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %v4i1_1 = extractelement <4 x i1> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %v8i1_1 = extractelement <8 x i1> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %v16i1_1 = extractelement <16 x i1> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 5 for instruction: %v32i1_1 = extractelement <32 x i1> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %nxv2i1_1 = extractelement <vscale x 2 x i1> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %nxv4i1_1 = extractelement <vscale x 4 x i1> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %nxv8i1_1 = extractelement <vscale x 8 x i1> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 5 for instruction: %nxv16i1_1 = extractelement <vscale x 16 x i1> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 9 for instruction: %nxv32i1_1 = extractelement <vscale x 32 x i1> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v2i8_1 = extractelement <2 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v4i8_1 = extractelement <4 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v8i8_1 = extractelement <8 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v16i8_1 = extractelement <16 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v32i8_1 = extractelement <32 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v64i8_1 = extractelement <64 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v128i8_1 = extractelement <128 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv2i8_1 = extractelement <vscale x 2 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv4i8_1 = extractelement <vscale x 4 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv8i8_1 = extractelement <vscale x 8 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv16i8_1 = extractelement <vscale x 16 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv32i8_1 = extractelement <vscale x 32 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv64i8_1 = extractelement <vscale x 64 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv128i8_1 = extractelement <vscale x 128 x i8> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v2i16_1 = extractelement <2 x i16> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v4i16_1 = extractelement <4 x i16> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v8i16_1 = extractelement <8 x i16> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v16i16_1 = extractelement <16 x i16> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v32i16_1 = extractelement <32 x i16> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v64i16_1 = extractelement <64 x i16> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv2i16_1 = extractelement <vscale x 2 x i16> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv4i16_1 = extractelement <vscale x 4 x i16> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv8i16_1 = extractelement <vscale x 8 x i16> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv16i16_1 = extractelement <vscale x 16 x i16> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv32i16_1 = extractelement <vscale x 32 x i16> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv64i16_1 = extractelement <vscale x 64 x i16> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v2i32_1 = extractelement <2 x i32> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v4i32_1 = extractelement <4 x i32> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v8i32_1 = extractelement <8 x i32> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v16i32_1 = extractelement <16 x i32> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v32i32_1 = extractelement <32 x i32> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv2i32_1 = extractelement <vscale x 2 x i32> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv4i32_1 = extractelement <vscale x 4 x i32> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv8i32_1 = extractelement <vscale x 8 x i32> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv16i32_1 = extractelement <vscale x 16 x i32> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv32i32_1 = extractelement <vscale x 32 x i32> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v2i64_1 = extractelement <2 x i64> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v4i64_1 = extractelement <4 x i64> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v8i64_1 = extractelement <8 x i64> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v16i64_1 = extractelement <16 x i64> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv2i64_1 = extractelement <vscale x 2 x i64> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv4i64_1 = extractelement <vscale x 4 x i64> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv8i64_1 = extractelement <vscale x 8 x i64> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %nxv16i64_1 = extractelement <vscale x 16 x i64> undef, i32 1
+; VISNI-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v2i1_x = extractelement <2 x i1> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v4i1_x = extractelement <4 x i1> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v8i1_x = extractelement <8 x i1> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v16i1_x = extractelement <16 x i1> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 6 for instruction: %v32i1_x = extractelement <32 x i1> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %nxv2i1_x = extractelement <vscale x 2 x i1> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %nxv4i1_x = extractelement <vscale x 4 x i1> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %nxv8i1_x = extractelement <vscale x 8 x i1> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 6 for instruction: %nxv16i1_x = extractelement <vscale x 16 x i1> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %nxv32i1_x = extractelement <vscale x 32 x i1> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v2i8_x = extractelement <2 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v4i8_x = extractelement <4 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v8i8_x = extractelement <8 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v16i8_x = extractelement <16 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v32i8_x = extractelement <32 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v64i8_x = extractelement <64 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v128i8_x = extractelement <128 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %nxv2i8_x = extractelement <vscale x 2 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %nxv4i8_x = extractelement <vscale x 4 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %nxv8i8_x = extractelement <vscale x 8 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %nxv16i8_x = extractelement <vscale x 16 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %nxv32i8_x = extractelement <vscale x 32 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %nxv64i8_x = extractelement <vscale x 64 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 18 for instruction: %nxv128i8_x = extractelement <vscale x 128 x i8> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v2i16_x = extractelement <2 x i16> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v4i16_x = extractelement <4 x i16> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v8i16_x = extractelement <8 x i16> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v16i16_x = extractelement <16 x i16> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v32i16_x = extractelement <32 x i16> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v64i16_x = extractelement <64 x i16> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %nxv2i16_x = extractelement <vscale x 2 x i16> undef, i32 %x
+; VISNI-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %nxv4i16_x = extractelement <vscale x 4 x i16> undef, i32 %...
[truncated]
|
You can test this locally with the following command:git diff -U0 --pickaxe-regex -S '([^a-zA-Z0-9#_-]undef[^a-zA-Z0-9_-]|UndefValue::get)' 'HEAD~1' HEAD llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp llvm/test/Analysis/CostModel/RISCV/rvv-extractelement.ll llvm/test/Analysis/CostModel/RISCV/rvv-insertelement.ll The following files introduce new uses of undef:
Undef is now deprecated and should only be used in the rare cases where no replacement is possible. For example, a load of uninitialized memory yields In tests, avoid using For example, this is considered a bad practice: define void @fn() {
...
br i1 undef, ...
} Please use the following instead: define void @fn(i1 %cond) {
...
br i1 %cond, ...
} Please refer to the Undefined Behavior Manual for more information. |
If we have the ri.vinsert/vextract instructions from xrivosvisni, we can do an element insert or extract without needing a vslide or a vector temporary register. Adjust the TTI cost to reflect this.