[PATCH] [X86] New pass that moves immediate operands to registers.

Pete Cooper peter_cooper at apple.com
Tue Sep 30 11:31:36 PDT 2014


Hi Serge, Quentin

In the specific example here for the constant 0, i’d have expected to see xor used to create the 0.  Any idea why that didn’t happen?  That would improve the code size which Quentin mentioned is a plus for this.

Also, i’ve sometimes seen neighboring 0’s being written of different sizes.  Would it be possible (perhaps in a future patch), to turn

movq 0, 0x0(%rsi)
movl 0, 0x8(%rsi)

in to

xor %rax, %rax
movq %rax, 0x0(%rsi)
movl %eax, 0x8(%rsi)

Thanks,
Pete

> On Sep 30, 2014, at 6:50 PM, Quentin Colombet <qcolombet at apple.com> wrote:
> 
> Hi Serge,
> 
> The constant hoisting pass does this kind of things. Should we try to teach it to handle this kind of cases?
> 
> Moreover, this may be beneficial for code size, but I guess it is generally not beneficial for performances. Therefore, I believe this should be done for functions with the Os or Oz attributes only.
> 
> CC’ed Juergen to have his thoughts on the constant hoisting stuff.
> 
> Thanks,
> -Quentin 
> On Sep 30, 2014, at 10:24 AM, Serge Pavlov <sepavloff at gmail.com> wrote:
> 
>> The pass scans machine instructions looking for uses of immediate
>> values. If the same value is used in neighbouring instructions, it
>> is moved to a register, if this is possible and reduces code size.
>> For instance, instructions
>> 
>>   mov $0, 0x4(%esi)
>>   mov $0, 0x8(%esi)
>> 
>> can be replaced by
>> 
>>   mov $0, %eax
>>   mov %eax, 0x4(%esi)
>>   mov %eax, 0x8(%esi)
>> 
>> which is shorter in code size.
>> 
>> This patch fixes PR5124, it uses feedback on the previous patch discussed in the thread
>> http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20130916/188079.html .
>> 
>> http://reviews.llvm.org/D5544
>> 
>> Files:
>> lib/Target/X86/CMakeLists.txt
>> lib/Target/X86/X86.h
>> lib/Target/X86/X86MaterializeImmediates.cpp
>> lib/Target/X86/X86TargetMachine.cpp
>> test/CodeGen/X86/coalescer-commute3.ll
>> test/CodeGen/X86/fast-isel-x86.ll
>> test/CodeGen/X86/materialize-imm.ll
>> test/CodeGen/X86/memcpy-2.ll
>> test/CodeGen/X86/memset.ll
>> test/CodeGen/X86/memset64-on-x86-32.ll
>> test/CodeGen/X86/nancvt.ll
>> test/CodeGen/X86/pr14562.ll
>> test/CodeGen/X86/pr18023.ll
>> test/CodeGen/X86/tlv-1.ll
>> test/CodeGen/X86/xmulo.ll
>> test/DebugInfo/X86/debug-loc-offset.ll
>> <D5544.14236.patch>_______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 
> 
> _______________________________________________
> 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/20140930/7e6b8fba/attachment.html>


More information about the llvm-commits mailing list