🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Bruno Haible Sun, 20 Dec 1992 00:45
missed long long optimizations on i386
#1573
Author: Bruno Haible
Date: Sun, 20 Dec 1992 00:45
76 lines
2455 bytes
This is not a bug report, only a hint that "long long" performance on
i386 may be improved.

I'm working with gcc 2.2.2, configured as i386-linux.

Input file:

============================== lltest.c =====================================
unsigned long foo (unsigned long long x)
{ return x & 0x00000000FFFFFFFFULL; }

unsigned long foo2 (unsigned long long x, unsigned long long y)
{ unsigned long long z = x + y;
  z &= 0x00000000FFFFFFFFULL;
  return z;
}

unsigned long long bar (void* addr)
{ return (unsigned long long)(unsigned long)(addr) + 0x0000000D00000000ULL; }

==============================================================================

Output from "gcc -O6 -S lltest.c", with comments:

================================= lltest.s ===================================
	.file	"lltest.c"
gcc2_compiled.:
.text
	.align 2
.globl _foo
_foo:
	pushl %ebp
	movl %esp,%ebp
	movl 8(%ebp),%eax
	movl 12(%ebp),%edx              ! superfluous
	leave
	ret
	.align 2,0x90
	.align 2
.globl _foo2
_foo2:
	pushl %ebp
	movl %esp,%ebp
	pushl %ebx
	movl 8(%ebp),%ecx
	movl 12(%ebp),%ebx
	addl 16(%ebp),%ecx
	adcl 20(%ebp),%ebx
	movl %ecx,%eax
	xorl %edx,%edx                   ! superfluous
	movl -4(%ebp),%ebx
	leave
	ret
	.align 2
.globl _bar
_bar:
	pushl %ebp
	movl %esp,%ebp
	movl 8(%ebp),%eax
	movl %eax,%edx                    !
	xorl %ecx,%ecx                    ! may be replaced by
	movl %edx,%eax                    ! a simple
	movl %ecx,%edx                    !
	addl $0,%eax                      !    movl $13,%edx
	adcl $13,%edx                     !
	leave
	ret
	.align 2,0x90
==============================================================================

Note further that gcc (even without -O) aborts like this on some bigger
functions that use many "long long" variables. I can provide examples.
   gcc: Internal compiler error: program cc1 got fatal signal 6

Bruno Haible
haible@ma2s2.mathematik.uni-karlsruhe.de
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads