[llvm] ab736a2 - [BasicTTI] Account for vector of pointers in getMemoryOpCost

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 25 12:11:13 PDT 2022


Should be fixed in b61235739, sorry for the breakage.

Philip

On 6/25/22 12:04, Philip Reames via llvm-commits wrote:
> This appears to have broken build for some targets due to not all 
> sub-classes having a datalayout field.  Testing a fix now, should have 
> it pushed in the next few minutes.
>
> Philip
>
> On 6/25/22 11:17, Philip Reames via llvm-commits wrote:
>> Author: Philip Reames
>> Date: 2022-06-25T11:11:58-07:00
>> New Revision: ab736a2750a99b303f8d6a216f754fb3577abb88
>>
>> URL: 
>> https://github.com/llvm/llvm-project/commit/ab736a2750a99b303f8d6a216f754fb3577abb88
>> DIFF: 
>> https://github.com/llvm/llvm-project/commit/ab736a2750a99b303f8d6a216f754fb3577abb88.diff
>>
>> LOG: [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
>>
>> Added:
>>
>> Modified:
>>      llvm/include/llvm/CodeGen/BasicTTIImpl.h
>>      llvm/test/Analysis/CostModel/RISCV/rvv-load-store.ll
>>
>> Removed:
>>
>>
>> ################################################################################ 
>>
>> diff  --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h 
>> b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
>> index 98cb4ebda8cf4..2ed687362cabd 100644
>> --- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h
>> +++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
>> @@ -1207,7 +1207,7 @@ class BasicTTIImplBase : public 
>> TargetTransformInfoImplCRTPBase<T> {
>>           // 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
>>
>> diff  --git a/llvm/test/Analysis/CostModel/RISCV/rvv-load-store.ll 
>> b/llvm/test/Analysis/CostModel/RISCV/rvv-load-store.ll
>> index e12a55e4eadf0..0a3135b78a851 100644
>> --- a/llvm/test/Analysis/CostModel/RISCV/rvv-load-store.ll
>> +++ b/llvm/test/Analysis/CostModel/RISCV/rvv-load-store.ll
>> @@ -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
>>
>>
>>          _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list