[PATCH] PR/34012, fwprop does not look at rtx_costs
Paolo Bonzini
paolo.bonzini@lu.unisi.ch
Thu Nov 8 17:17:00 GMT 2007
Unlike CSE, fwprop has never looked at rtx_costs except for addressing
mode selection. This causes pessimizations, for example when the same
expensive constant is used in many insns. Then it is:
1) moved to a register by CSE
2) moved back as an immediate by fwprop
3) split, or reloaded, into a different register for every insn, causing
worse code overall.
Example with -fno-forward-propagate:
movabsq $578721382704613384, %rax
movq %rsp, %rdi
movq %rax, (%rsp)
movq %rax, 8(%rsp)
movq %rax, 16(%rsp)
movq %rax, 24(%rsp)
movq %rax, 32(%rsp)
movq %rax, 40(%rsp)
movq %rax, 48(%rsp)
movq %rax, 56(%rsp)
movq %rax, 64(%rsp)
movq %rax, 72(%rsp)
becomes with fwprop enabled:
movabsq $578721382704613384, %rax
movabsq $578721382704613384, %r11
movq %rax, (%rsp)
movabsq $578721382704613384, %rax
movq %rsp, %rdi
movq %rax, 8(%rsp)
movabsq $578721382704613384, %r10
movabsq $578721382704613384, %r9
movabsq $578721382704613384, %r8
movabsq $578721382704613384, %rsi
movabsq $578721382704613384, %rcx
movabsq $578721382704613384, %rdx
movabsq $578721382704613384, %rax
movq %r11, 16(%rsp)
movq %r10, 24(%rsp)
movq %r9, 32(%rsp)
movq %r8, 40(%rsp)
movq %rsi, 48(%rsp)
movq %rcx, 56(%rsp)
movq %rdx, 64(%rsp)
movq %rax, 72(%rsp)
The solution is to reject replacing a value if it makes the destination
of the propagation more expensive.
Ok?
Paolo
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pr34012.patch
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20071108/95ca787c/attachment.ksh>
More information about the Gcc-patches
mailing list