forked from OSchip/llvm-project
[BasicTTI] Account for vector of pointers in getMemoryOpCost
By using getPrimitiveSizeInBits, we were getting 0 for every pointer type. This code is trying to account for the cost of truncating a store or extending a load to convert from the source vector element type to the legal vector element type.
I'd originally seen this as a crash when trying to scalarize a <vscale x 1 x ptr> type coming from the vectorizer. Here's a minimum reproducer to exercise the code in question.
void e(int *argv[], int *p) {
for (int i = 0; i < 1024; i++)
argv[i] = p;
}
This was checked in as the splat_ptr test in 2cf320d
. After bbf3fd, this no longer crashes since we correctly return invalid if the extending load/truncating store isn't legal.
Differential Revision: https://reviews.llvm.org/D128228
This commit is contained in:
parent
767ba58f80
commit
ab736a2750
|
@ -1207,7 +1207,7 @@ public:
|
|||
// In practice it's not currently possible to have a change in lane
|
||||
// length for extending loads or truncating stores so both types should
|
||||
// have the same scalable property.
|
||||
TypeSize::isKnownLT(Src->getPrimitiveSizeInBits(),
|
||||
TypeSize::isKnownLT(DL.getTypeStoreSizeInBits(Src),
|
||||
LT.second.getSizeInBits())) {
|
||||
// This is a vector load that legalizes to a larger type than the vector
|
||||
// itself. Unless the corresponding extending load or truncating store is
|
||||
|
|
|
@ -58,16 +58,16 @@ define void @load(ptr %p) {
|
|||
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %51 = load <vscale x 16 x i64>, ptr %p, align 128
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %52 = load <vscale x 32 x i64>, ptr %p, align 256
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %53 = load ptr, ptr %p, align 8
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %54 = load <1 x ptr>, ptr %p, align 8
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %55 = load <2 x ptr>, ptr %p, align 16
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %54 = load <1 x ptr>, ptr %p, align 8
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %55 = load <2 x ptr>, ptr %p, align 16
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %56 = load <4 x ptr>, ptr %p, align 32
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %57 = load <8 x ptr>, ptr %p, align 64
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %58 = load <16 x ptr>, ptr %p, align 128
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %59 = load <32 x ptr>, ptr %p, align 256
|
||||
; CHECK-NEXT: Cost Model: Invalid cost for instruction: %60 = load <vscale x 1 x ptr>, ptr %p, align 8
|
||||
; CHECK-NEXT: Cost Model: Invalid cost for instruction: %61 = load <vscale x 2 x ptr>, ptr %p, align 16
|
||||
; CHECK-NEXT: Cost Model: Invalid cost for instruction: %62 = load <vscale x 4 x ptr>, ptr %p, align 32
|
||||
; CHECK-NEXT: Cost Model: Invalid cost for instruction: %63 = load <vscale x 8 x ptr>, ptr %p, align 64
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %60 = load <vscale x 1 x ptr>, ptr %p, align 8
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %61 = load <vscale x 2 x ptr>, ptr %p, align 16
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %62 = load <vscale x 4 x ptr>, ptr %p, align 32
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %63 = load <vscale x 8 x ptr>, ptr %p, align 64
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %64 = load <vscale x 16 x ptr>, ptr %p, align 128
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %65 = load <vscale x 32 x ptr>, ptr %p, align 256
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret void
|
||||
|
@ -201,18 +201,18 @@ define void @store(ptr %p) {
|
|||
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: store <vscale x 16 x i64> undef, ptr %p, align 128
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: store <vscale x 32 x i64> undef, ptr %p, align 256
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store ptr undef, ptr %p, align 8
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: store <1 x ptr> undef, ptr %p, align 8
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 3 for instruction: store <2 x ptr> undef, ptr %p, align 16
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 6 for instruction: store <4 x ptr> undef, ptr %p, align 32
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 12 for instruction: store <8 x ptr> undef, ptr %p, align 64
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 24 for instruction: store <16 x ptr> undef, ptr %p, align 128
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 48 for instruction: store <32 x ptr> undef, ptr %p, align 256
|
||||
; CHECK-NEXT: Cost Model: Invalid cost for instruction: store <vscale x 1 x ptr> undef, ptr %p, align 8
|
||||
; CHECK-NEXT: Cost Model: Invalid cost for instruction: store <vscale x 2 x ptr> undef, ptr %p, align 16
|
||||
; CHECK-NEXT: Cost Model: Invalid cost for instruction: store <vscale x 4 x ptr> undef, ptr %p, align 32
|
||||
; CHECK-NEXT: Cost Model: Invalid cost for instruction: store <vscale x 8 x ptr> undef, ptr %p, align 64
|
||||
; CHECK-NEXT: Cost Model: Invalid cost for instruction: store <vscale x 16 x ptr> undef, ptr %p, align 128
|
||||
; CHECK-NEXT: Cost Model: Invalid cost for instruction: store <vscale x 32 x ptr> undef, ptr %p, align 256
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store <1 x ptr> undef, ptr %p, align 8
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store <2 x ptr> undef, ptr %p, align 16
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: store <4 x ptr> undef, ptr %p, align 32
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: store <8 x ptr> undef, ptr %p, align 64
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 8 for instruction: store <16 x ptr> undef, ptr %p, align 128
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 16 for instruction: store <32 x ptr> undef, ptr %p, align 256
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store <vscale x 1 x ptr> undef, ptr %p, align 8
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store <vscale x 2 x ptr> undef, ptr %p, align 16
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store <vscale x 4 x ptr> undef, ptr %p, align 32
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store <vscale x 8 x ptr> undef, ptr %p, align 64
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: store <vscale x 16 x ptr> undef, ptr %p, align 128
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: store <vscale x 32 x ptr> undef, ptr %p, align 256
|
||||
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret void
|
||||
;
|
||||
store i8 undef, ptr %p
|
||||
|
|
Loading…
Reference in New Issue