[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#204687: gcc-3.3: gcc should use xor trick with -Os



Package: gcc-3.3
Version: 1:3.3.1-0pre0
Severity: wishlist

The program

--
#include <linux/time.h>

void foo(struct timespec *t, struct timespec *u)
{
	struct timespec zero = {0, 0};

	*t = zero;
	*u = zero;
}
--

produces the following code on i386 with -Os

--
	.file	"b.c"
	.text
.globl foo
	.type	foo, @function
foo:
	pushl	%ebp
	movl	%esp, %ebp
	movl	8(%ebp), %eax
	movl	$0, (%eax)
	movl	$0, 4(%eax)
	movl	12(%ebp), %eax
	movl	$0, (%eax)
	movl	$0, 4(%eax)
	leave
	ret
	.size	foo, .-foo
	.ident	"GCC: (GNU) 3.3.1 20030626 (Debian prerelease)"
--

It would be much better size-wise if it stored a zero in a register
and then stored the register into those locations.

-- System Information
Debian Release: testing/unstable
Kernel Version: Linux gondolin 2.4.21-2-686-smp #1 SMP Sat Jul 5 01:42:22 EST 2003 i686 GNU/Linux

Versions of the packages gcc-3.3 depends on:
ii  binutils       2.14.90.0.4-0. The GNU assembler, linker and binary utiliti
ii  cpp-3.3        3.3.1-0pre0    The GNU C preprocessor
ii  gcc-3.3-base   3.3.1-0pre0    The GNU Compiler Collection (base package)
ii  libc6          2.3.1-16       GNU C Library: Shared libraries and Timezone
ii  libgcc1        3.3.1-0pre0    GCC support library



Reply to: