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

Bug#94701: gcc-3.0: Duplicate loop conditions even with -Os



Package: gcc-3.0
Version: 1:3.0-0pre010403
Severity: wishlist

For the following program,

int k;

extern void b();

int a(int i) {
	while (k < i) {
		b();
	}
}

GCC generates this on i386 (gcc -S -Os),

a:
	pushl	%ebp
	movl	%esp, %ebp
	pushl	%ebx
	pushl	%ecx
	movl	8(%ebp), %ebx
	cmpl	%ebx, k
	jge	.L7
	.p2align 2
.L5:
	call	b
	cmpl	%ebx, k
	jl	.L5
.L7:
	popl	%edx
	popl	%ebx
	popl	%ebp
	ret

I don't see the reason why it isn't doing:

	.p2align 2
.L5:
	cmpl	%ebx, k
	jge	.L7
	call	b
	jmp	.L5
.L7:

or

	jmp	.L7
	.p2align 2
.L5:
	call	b
.L7:
	cmpl	%ebx, k
	jl	.L5

-- System Information
Debian Release: testing/unstable
Kernel Version: Linux gondolin 2.4.3-pentiumiii-smp #1 SMP Sun Apr 15 14:20:42 EST 2001 i686 unknown

Versions of the packages gcc-3.0 depends on:
ii  binutils       2.11.90.0.1-1  The GNU assembler, linker and binary utiliti
ii  cpp-3.0        3.0-0pre010403 The GNU C preprocessor.
ii  gcc-3.0-base   3.0-0pre010403 The GNU compiler collection (base package).
ii  libc6          2.2.2-4        GNU C Library: Shared libraries and Timezone
ii  libgcc300      3.0-0pre010403 Shared libgcc.



Reply to: