This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug rtl-optimization/15556] New: Idiom for "xchg %ah,%al" not recognized


When compiling:
#define regparm __attribute__((regparm(3)))
unsigned short regparm a(unsigned short x) { return (x << 8) | (x >> 8); }
unsigned short regparm b(unsigned short x) { return (x >> 8) | (x << 8); }

With:
gcc -W -Wall -O3 -ffast-math -fomit-frame-pointer -fexpensive-optimizations
-save-temps -march=athlon -c

The result is:
	.file	"testcase.c"
	.text
	.align 4
	.p2align 4,,15
.globl a
	.type	a, @function
a:
	movzwl	%ax, %edx
	shrw	$8, %ax
	sall	$8, %edx
	orl	%edx, %eax
	movzwl	%ax, %eax
	ret
	.size	a, .-a
	.p2align 4,,15
.globl b
	.type	b, @function
b:
	movl	%eax, %edx
	movzwl	%ax, %eax
	sall	$8, %eax
	shrw	$8, %dx
	orl	%eax, %edx
	movzwl	%dx, %eax
	ret
	.size	b, .-b
	.ident	"GCC: (GNU) 3.5.0 20040512 (experimental)"
	.section	.note.GNU-stack,"",@progbits

What I expected for both a and b is:
	xchg	%ah, %al
	ret

or maybe:
	xchg	%al, %ah
	ret

Reading specs from /usr/lib/gcc-snapshot/lib/gcc/i486-linux/3.5.0/specs
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f77,objc,ada,treelang
--prefix=/usr/lib/gcc-snapshot --enable-shared --with-system-zlib --enable-nls
--enable-threads=posix --without-included-gettext --disable-werror
--enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug
--enable-java-gc=boehm --enable-java-awt=gtk i486-linux
Thread model: posix
gcc version 3.5.0 20040512 (experimental)

-- 
           Summary: Idiom for "xchg %ah,%al" not recognized
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: cesarb at nitnet dot com dot br
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15556


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]