This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/54904] New: Large mode constant live in a register not used to optimize smaller mode constants
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 11 Oct 2012 19:53:42 +0000
- Subject: [Bug target/54904] New: Large mode constant live in a register not used to optimize smaller mode constants
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54904
Bug #: 54904
Summary: Large mode constant live in a register not used to
optimize smaller mode constants
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: jakub@gcc.gnu.org
CC: uros@gcc.gnu.org
void
foo (char *p)
{
__builtin_memset (p, 0x11, 23);
}
results in terrible code on x86_64-linux at -O2:
movabsq $1229782938247303441, %rax
movl $286331153, 16(%rdi)
movb $17, 22(%rdi)
movq %rax, (%rdi)
movq %rax, 8(%rdi)
movl $4369, %eax
movw %ax, 20(%rdi)
ret
E.g.
movabsq $1229782938247303441, %rax
movl %eax, 16(%rdi)
movb %al, 22(%rdi)
movq %rax, (%rdi)
movq %rax, 8(%rdi)
movw %ax, 20(%rdi)
ret
would be 10 bytes shorter. Guess we don't want to do this kind of
optimizations before RA, it might increase register preassure, but somewhere
close to final would be nice. Use a register instead of immediate if it is
available, makes the insn smaller and not slower.