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

Quentin Colombet qcolombet at apple.com
Tue Sep 30 10:50:49 PDT 2014


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





More information about the llvm-commits mailing list