[Bug rtl-optimization/13355] Suboptimal code generated with global register variables
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=13355 Martin Sebor changed: What|Removed |Added Status|NEW |RESOLVED CC||msebor at gcc dot gnu.org Resolution|--- |FIXED --- Comment #12 from Martin Sebor --- Wiuth today's top of trunk (GCC 7.0) the object code below matches closely the assembly expected in comment #3. Resolving as fixed. op_imull_EAX_T0: .LFB1: .cfi_startproc movl%ebx, %eax imull 0(%ebp) movl%edx, %ecx movl%eax, %edx movl%eax, 0(%ebp) movl%edx, %eax cltd xorl%eax, %eax cmpl%ecx, %edx setne %al movl%ecx, 8(%ebp) movl%eax, 32(%ebp) ret
[Bug rtl-optimization/13355] Suboptimal code generated with global register variables
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13355 --- Comment #9 from Steven Bosscher steven at gcc dot gnu.org 2012-11-08 22:41:41 UTC --- (In reply to comment #6) A reduced testcase for the second case. On mainline, i686-pc-linux-gnu. /* -march=i686 -mtune=i686 -fomit-frame-pointer -O2 */ register int ebx asm (ebx); register int dummy1 asm (esi); register int dummy2 asm (ebp); int foo (int arg) { long long res = (long long) arg * (long long) ebx; return (int) res; } Global variables take up three registers from IA-32! GCC 4.1, GCC 4.3, and GCC 4.7 compile this to: foo: subl$12, %esp movl16(%esp), %eax imull %ebx movl%eax, (%esp) movl(%esp), %eax movl%edx, 4(%esp) addl$12, %esp ret Trunk r193340 compiles it to: foo: movl%ebx, %eax imull 4(%esp) ret
[Bug rtl-optimization/13355] Suboptimal code generated with global register variables
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13355 Steven Bosscher steven at gcc dot gnu.org changed: What|Removed |Added CC||steven at gcc dot gnu.org --- Comment #10 from Steven Bosscher steven at gcc dot gnu.org 2012-11-08 22:46:53 UTC --- (In reply to comment #1) Created attachment 5301 [details] example .c file that shows behavior with gcc -march=i686 -mtune=i686 -fomit-frame-pointer -O2 test.c GCC 4.7.1 compiles the two interesting functions in the test case to: op_cmovl_EAX_T1_T0: testl %ebx, %ebx je .L2 movl%esi, 0(%ebp) .L2: ret op_imull_EAX_T0: subl$20, %esp movl0(%ebp), %eax imull %ebx movl%eax, (%esp) movl%eax, 0(%ebp) movl(%esp), %eax movl%edx, 4(%esp) movl%edx, 8(%ebp) movl%eax, %edx movl%eax, 8(%esp) sarl$31, %edx movl4(%esp), %eax movl%edx, 12(%esp) cmpl%eax, 12(%esp) setne %al movzbl %al, %eax movl%eax, 32(%ebp) addl$20, %esp ret Trunk r193340 produces the following: op_cmovl_EAX_T1_T0: testl %ebx, %ebx je .L2 movl%esi, 0(%ebp) .L2: ret op_imull_EAX_T0: subl$12, %esp movl%ebx, %eax imull 0(%ebp) movl%eax, 0(%ebp) movl%eax, (%esp) sarl$31, %eax movl%eax, 4(%esp) xorl%eax, %eax cmpl%edx, 4(%esp) movl%edx, 8(%ebp) setne %al movl%eax, 32(%ebp) addl$12, %esp ret
[Bug rtl-optimization/13355] Suboptimal code generated with global register variables
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13355 Steven Bosscher steven at gcc dot gnu.org changed: What|Removed |Added CC|steven at gcc dot gnu.org | --- Comment #11 from Steven Bosscher steven at gcc dot gnu.org 2012-11-08 22:50:51 UTC --- So, not quite the code of comment #3, but LRA does appear to improve things quite a bit. I'll leave it to the OP to decide whether this bug report is resolved sufficiently well to close it.
[Bug rtl-optimization/13355] Suboptimal code generated with global register variables
--- Additional Comments From pinskia at gcc dot gnu dot org 2005-03-29 01:55 --- Some of this is already fixed. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13355