[llvm] r209162 - [ConstantHoisting][X86] Change the cost model to never hoist constants for types larger than i128.

Juergen Ributzka juergen at apple.com
Mon May 19 14:44:54 PDT 2014


I filed http://llvm.org/bugs/show_bug.cgi?id=19797

On May 19, 2014, at 2:28 PM, Quentin Colombet <qcolombet at apple.com> wrote:

> Hi Juergen,
> 
> Could you file a PR for the actual issue?
> 
> Thanks,
> -Quentin
> 
> On May 19, 2014, at 2:00 PM, Juergen Ributzka <juergen at apple.com> wrote:
> 
>> Author: ributzka
>> Date: Mon May 19 16:00:53 2014
>> New Revision: 209162
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=209162&view=rev
>> Log:
>> [ConstantHoisting][X86] Change the cost model to never hoist constants for types larger than i128.
>> 
>> Currently the X86 backend doesn't support types larger than i128 very well. For
>> example an i192 multiply will assert in codegen when the 2nd argument is a constant and the constant got hoisted.
>> 
>> This fix changes the cost model to never hoist constants for types larger than
>> i128. Once the codegen issues have been resolved, the cost model can be updated
>> to allow also larger types.
>> 
>> This is related to <rdar://problem/16954938>
>> 
>> Modified:
>>    llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp
>>    llvm/trunk/test/Transforms/ConstantHoisting/X86/large-immediate.ll
>> 
>> Modified: llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp?rev=209162&r1=209161&r2=209162&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp (original)
>> +++ llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp Mon May 19 16:00:53 2014
>> @@ -815,6 +815,13 @@ unsigned X86TTI::getIntImmCost(const API
>>   if (BitSize == 0)
>>     return ~0U;
>> 
>> +  // Never hoist constants larger than 128bit, because this might lead to
>> +  // incorrect code generation or assertions in codegen.
>> +  // Fixme: Create a cost model for types larger than i128 once the codegen
>> +  // issues have been fixed.
>> +  if (BitSize > 128)
>> +    return TCC_Free;
>> +
>>   if (Imm == 0)
>>     return TCC_Free;
>> 
>> @@ -830,8 +837,10 @@ unsigned X86TTI::getIntImmCost(unsigned
>>   assert(Ty->isIntegerTy());
>> 
>>   unsigned BitSize = Ty->getPrimitiveSizeInBits();
>> +  // There is no cost model for constants with a bit size of 0. Return TCC_Free
>> +  // here, so that constant hoisting will ignore this constant.
>>   if (BitSize == 0)
>> -    return ~0U;
>> +    return TCC_Free;
>> 
>>   unsigned ImmIdx = ~0U;
>>   switch (Opcode) {
>> @@ -892,8 +901,10 @@ unsigned X86TTI::getIntImmCost(Intrinsic
>>   assert(Ty->isIntegerTy());
>> 
>>   unsigned BitSize = Ty->getPrimitiveSizeInBits();
>> +  // There is no cost model for constants with a bit size of 0. Return TCC_Free
>> +  // here, so that constant hoisting will ignore this constant.
>>   if (BitSize == 0)
>> -    return ~0U;
>> +    return TCC_Free;
>> 
>>   switch (IID) {
>>   default: return TCC_Free;
>> 
>> Modified: llvm/trunk/test/Transforms/ConstantHoisting/X86/large-immediate.ll
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ConstantHoisting/X86/large-immediate.ll?rev=209162&r1=209161&r2=209162&view=diff
>> ==============================================================================
>> --- llvm/trunk/test/Transforms/ConstantHoisting/X86/large-immediate.ll (original)
>> +++ llvm/trunk/test/Transforms/ConstantHoisting/X86/large-immediate.ll Mon May 19 16:00:53 2014
>> @@ -16,3 +16,12 @@ define i512 @test2(i512 %a) nounwind {
>>   %2 = ashr i512 %1, 504
>>   ret i512 %2
>> }
>> +
>> +; Check that we don't hoist constants with a type larger than i128.
>> +define i196 @test3(i196 %a) nounwind {
>> +; CHECK-LABEL: test3
>> +; CHECK-NOT: %const = bitcast i196 2 to i196
>> +  %1 = mul i196 %a, 2
>> +  %2 = mul i196 %1, 2
>> +  ret i196 %2
>> +}
>> 
>> 
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140519/f41ee9d5/attachment.html>


More information about the llvm-commits mailing list