From owner-freebsd-java Sat Feb 15 9:45:46 2003 Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2B8B537B401 for ; Sat, 15 Feb 2003 09:45:43 -0800 (PST) Received: from gddsn.org.cn (mail.gddsn.org.cn [210.21.6.33]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8A41143F75 for ; Sat, 15 Feb 2003 09:45:42 -0800 (PST) (envelope-from hwh@gddsn.org.cn) Received: from gddsn.org.cn (gw [210.21.6.34]) by gddsn.org.cn (Postfix) with ESMTP id 72C5738CB49 for ; Sun, 16 Feb 2003 01:45:41 +0800 (CST) Message-ID: <3E4E7CC5.8040400@gddsn.org.cn> Date: Sun, 16 Feb 2003 01:45:41 +0800 From: Huang wen hui User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; zh-CN; rv:1.1) Gecko/20021225 X-Accept-Language: zh-cn, zh-tw, en-us MIME-Version: 1.0 To: java@FreeBSD.ORG Subject: Re: Optimization problem (Re: Math.pow bug for jdk1.3.1-p8 ?) References: <3E4C9DDD.4040204@gddsn.org.cn> <20030215.175421.1015281127.shudo@localhost> <20030216014802.A10817@misty.eyesbeyond.com> <20030216.005020.894433699.shudo@localhost> <3E4E7728.8030803@gddsn.org.cn> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org Huang wen hui wrote: > shudo@computer.org ??: > >> From: Greg Lewis >> >> >> >>> On Sat, Feb 15, 2003 at 05:54:21PM +0900, shudo@computer.org wrote: >>> >>> >>>> I could confirm __j__ieee754_pow() in libjava.so behaves wrong and one >>>> in libjava_g.so works correctly. >>>> >>>> I also tried writing a test program which calls __j__ieee754_pow() and >>>> linked the program with e_pow.o, w_sqrt.o, e_sqrt.o, s_fabs.o, >>>> s_scalbn.o and s_copysign.o generated during compilation process of >>>> JDK 1.3.1. The program produces the incorrect value (0, not 512). >>>> >>>> It is certain that there is a problem around fdlibm, FreeBSD's gcc >>>> 2.95.4 or how the fdlibm compiled (compiler flags?). >>>> >>> >>> Sounds like its quite possibly due to problems with optimisation. >>> Obviously, java_g uses no optimisation when compiling, >>> >> >> >> I agree with you. >> >> Next thing we can do to track the cause down is to compile e_pow.c, >> w_sqrt.c, e_sqrt.c, s_fabs.c, s_scalbn.c and s_copysign.c with >> different compiler options (-O0, -O2 and so on) and see the result of >> the ieee754_pow() function. It may be good to supply different >> options to each source code and identify which source code is badly >> affected by optimization. >> >> We should report the bug of FreeBSD's gcc 2.95.4 to appropriate >> persons if we could recognize the problem is due to the gcc. >> >> Kazuyuki Shudo shudo@computer.org http://www.shudo.net/ >> >> To Unsubscribe: send mail to majordomo@FreeBSD.org >> with "unsubscribe freebsd-java" in the body of the message >> >> >> >> > This code is from > j2sdk1.3.1/src/share/native/java/lang/fdlibm/src/e_pow.c in jdk13 > ports, gcc's optimization may has problem. > > #include > > #define __HI(x) *(1+(int*)&x) > #define __LO(x) *(int*)&x > > > double tst(double x, double y) > { > double z,ax,z_h,z_l,p_h,p_l; > double y1,t1,t2,r,s,t,u,v,w; > int i,j,k,yisint,n; > int hx,hy,ix,iy; > unsigned lx,ly; > > u=1; > v=1; > t1=u+v; > __LO(t1) = 0; > > > t2=10; > y1 = y; > __LO(y1) = 0; > p_l = (y-y1)*t1+y*t2; > p_h = y1*t1; > z = p_l+p_h; // return t1; //ok > j = __HI(z); // return t1; //bad t1 > return t1; > } > main() { > double d = tst(2.0,9.0); > printf("%f\n", d); > } > > ----output---- > gcc -O3 -o tst tst.c > # ./tst > 0.000000 > # gcc -O2 -o tst tst.c > # ./tst > 0.000000 > # gcc -O1 -o tst tst.c > # ./tst > 0.000000 > # gcc -O0 -o tst tst.c > # ./tst > 2.000000 > # gcc -v > Using builtin specs. > gcc version 2.95.4 20020320 [FreeBSD] > # uname -a > FreeBSD wfdb.gddsn.org.cn 4.7-STABLE FreeBSD 4.7-STABLE #0: Fri Feb 14 > 12:04:07 CST 2003 root@wfdb.gddsn.org.cn:/usr/obj/usr/src/sys/WFDB i386 > > > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-java" in the body of the message > > oh, btw, I use gcc3.2.2 under CURRENT do not have this problem, so I think use gcc322 to compile jdk13 should be ok. I will try it later. --hwh. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message