From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29904 invoked by alias); 26 Aug 2011 12:55:55 -0000 Received: (qmail 29895 invoked by uid 22791); 26 Aug 2011 12:55:55 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-gy0-f175.google.com (HELO mail-gy0-f175.google.com) (209.85.160.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 26 Aug 2011 12:55:40 +0000 Received: by gyg4 with SMTP id 4so2878215gyg.20 for ; Fri, 26 Aug 2011 05:55:39 -0700 (PDT) MIME-Version: 1.0 Received: by 10.150.61.12 with SMTP id j12mr2228268yba.22.1314363338227; Fri, 26 Aug 2011 05:55:38 -0700 (PDT) Received: by 10.150.57.5 with HTTP; Fri, 26 Aug 2011 05:55:38 -0700 (PDT) In-Reply-To: References: Date: Fri, 26 Aug 2011 12:55:00 -0000 Message-ID: Subject: Re: linking time eroor with -fast-math -O0 From: Richard Guenther To: Vladimir Yakovlev Cc: gcc@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2011-08/txt/msg00420.txt.bz2 On Fri, Aug 26, 2011 at 2:52 PM, Vladimir Yakovlev w= rote: > Hi, > > Following test fails in linking if compiled with ffast-math and O0, > but it compiled successfully with ffast-math and O2. Also no problem > if -lm is added. > > $ cat t.c > #include > > float foo(float x) > { > =A0 float y =3D 0; > =A0 while (x > 0.00000001) { > =A0 =A0 y +=3D x*x*x*x*x*x*x*x*x*x*x*x*x; > =A0 =A0 x =3D x/2; > =A0 } > =A0 return y; > } > > int main (int argc, char =A0 =A0*argv[]) > { > =A0float y =3D atoi(argv[1]); > =A0printf("%f\n", foo(y)); > =A0return 0; > } > > > $ gcc =A0-ffast-math -O0 =A0 t.c > /tmp/cccA1sUB.o: In function `foo': > t.c:(.text+0x2c): undefined reference to `powf' > collect2: error: ld returned 1 exit status > $ gcc =A0-ffast-math -O2 =A0 t.c > $ ./a.out 5 > 1220852096.000000 > > > FE with -ffast-math replaced x*x*...*x with __builtin_powf. Later with > -O2 this call is replaced back into multiplications in sincos phase. > The stability with -O0 is because sincos phase doesn't work on -O0. > > I think we must avoid doing this optimization in FE and turn off > -ffast-math if -O0 is used. Your opinion. No, I think we should avoid most of the builtin related folding at -O0. Can you open a bugreport on gcc.gnu.org/bugzilla please? Thanks, Richard. > Thanks, > Vladimir >