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

Bug#105309: gcc-3.0: i386 optimisation: joining tests



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

Here's another segment that needs to have an assembler optimiser run over it:

int foo(char c) {
	if (c && !(c & 0x80)) {
		a();
	} else {
		b();
	}
}

produces with -O2:

   0:	55                   	push   %ebp
   1:	89 e5                	mov    %esp,%ebp
   3:	83 ec 08             	sub    $0x8,%esp
   6:	8a 45 08             	mov    0x8(%ebp),%al
   9:	84 c0                	test   %al,%al
   b:	74 04                	je     11 <foo+0x11>
   d:	84 c0                	test   %al,%al
   f:	79 07                	jns    18 <foo+0x18>

9-f can be rewritten as:

test	%al, %al
jg	18

  11:	e8 fc ff ff ff       	call   12 <foo+0x12>
			12: R_386_PC32	b
  16:	c9                   	leave  
  17:	c3                   	ret    
  18:	e8 fc ff ff ff       	call   19 <foo+0x19>
			19: R_386_PC32	a
  1d:	eb f7                	jmp    16 <foo+0x16>

And what purpose does this jmp serve? Surely it can be replaced with

leave
ret

  1f:	90                   	nop    

-- System Information
Debian Release: testing/unstable
Kernel Version: Linux gondolin 2.4.6-686-smp #1 SMP Thu Jul 5 22:06:27 EST 2001 i686 unknown

Versions of the packages gcc-3.0 depends on:
ii  binutils       2.11.90.0.7-2  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.3-5        GNU C Library: Shared libraries and Timezone
ii  libgcc0        3.0-0pre010427 Shared libgcc.



Reply to: