Date: Mon, 12 Aug 2002 10:33:17 +0200 From: Dan Lukes <dan@obluda.cz> To: David Malone <dwmalone@maths.tcd.ie> Cc: freebsd-bugs@FreeBSD.org, bde@FreeBSD.org Subject: Re: bin/40209: __dtoa broken with -O2 or -O3 optimisation Message-ID: <3D5772CD.7000908@obluda.cz> References: <200207150140.g6F1e4SI056496@freefall.freebsd.org> <20020811212701.GA95745@walton.maths.tcd.ie>
next in thread | previous in thread | raw e-mail | index | archive | help
My knowledge about (optimization of) compilation theory isn't sufficient. I never listen about "aliasing rules". Where I can found something to read about it ? Despite of it, it is posible and not so expensive to detect that LHS point to the same place as another variable, so gcc should know about dependency between "x" and wordX(x). E.g., it construct may violate something, but gcc shall detect it and (at least) warn. Well, back to main problem. Yes, it works. Patch follow: *** lib/libc/stdlib/strtod.c.ORIG Tue May 28 18:59:40 2002 --- lib/libc/stdlib/strtod.c Mon Aug 12 10:23:52 2002 *************** *** 222,233 **** Only one of IEEE_LITTLE_ENDIAN, IEEE_BIG_ENDIAN, VAX, or IBM should be defined. #endif #ifdef IEEE_LITTLE_ENDIAN ! #define word0(x) ((ULong *)&x)[1] ! #define word1(x) ((ULong *)&x)[0] #else ! #define word0(x) ((ULong *)&x)[0] ! #define word1(x) ((ULong *)&x)[1] #endif /* The following definition of Storeinc is appropriate for MIPS processors. --- 222,237 ---- Only one of IEEE_LITTLE_ENDIAN, IEEE_BIG_ENDIAN, VAX, or IBM should be defined. #endif + union doubleasulongs { + double x; + ULong w[2]; + }; #ifdef IEEE_LITTLE_ENDIAN ! #define word0(x) (((union doubleasulongs *)&x)->w)[1] ! #define word1(x) (((union doubleasulongs *)&x)->w)[0] #else ! #define word0(x) (((union doubleasulongs *)&x)->w)[0] ! #define word1(x) (((union doubleasulongs *)&x)->w)[1] #endif /* The following definition of Storeinc is appropriate for MIPS processors. -- Dan Lukes tel: +420 2 21914205, fax: +420 2 21914206 root of FIONet, KolejNET, webmaster of www.freebsd.cz AKA: dan@obluda.cz, dan@freebsd.cz,dan@kolej.mff.cuni.cz To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3D5772CD.7000908>