Subject: toolchain/20623: powerpc-cc -mcpu=403 generates wrong code
To: None <>
From: Juergen Hannken-Illjes <>
List: netbsd-bugs
Date: 03/08/2003 18:31:32
>Number:         20623
>Category:       toolchain
>Synopsis:       powerpc-cc -mcpu=403 generates wrong code
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Mar 08 09:32:00 PST 2003
>Originator:     Juergen Hannken-Illjes
>Release:        NetBSD 1.6N
Architecture: powerpc
Machine: powerpc
	The following function

inet_pton4(const char *src, unsigned char *dst)
        unsigned long val;

        val = src[0];

        if (dst)
                memcpy(dst, &val, 4);

        return (1);

	gets compiled (using -m403) as:

        mr. 4,4
        lbz 0,0(3)
        bc 12,2,.L3
        stw 0,0(4)
        li 3,1

	The "memcpy" is reduced to "stw 0,0(4)". If "dst" is not 32bit
	aligned, this results in an alignment exception.
	See above.
	This fix removes the problem but I don't know if it is the right way
	to go ...

RCS file: /cvsroot/src/gnu/dist/toolchain/gcc/config/rs6000/netbsd.h,v
retrieving revision 1.8
diff -u -2 -r1.8 netbsd.h
--- netbsd.h	2003/02/28 17:30:16	1.8
+++ netbsd.h	2003/03/08 17:14:47
@@ -47,5 +47,5 @@
    We avoid their use here. */
 #undef	CC1_SPEC
-#define	CC1_SPEC	"-mno-multiple"
+#define	CC1_SPEC	"-mno-multiple -mstrict-align"
 /* Provide a LINK_SPEC approriate for NetBSD. */