From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24592 invoked by alias); 4 Jun 2002 06:56:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 24577 invoked by uid 71); 4 Jun 2002 06:56:01 -0000 Date: Mon, 03 Jun 2002 23:56:00 -0000 Message-ID: <20020604065601.24576.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: "Michael Veksler" Subject: Re: c++/6914: -O2 and -O give different results for the same valid FP code Reply-To: "Michael Veksler" X-SW-Source: 2002-06/txt/msg00079.txt.bz2 List-Id: The following reply was made to PR c++/6914; it has been noted by GNATS. From: "Michael Veksler" To: Franz Sirl Cc: tprince@computer.org, gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Subject: Re: c++/6914: -O2 and -O give different results for the same valid FP code Date: Tue, 4 Jun 2002 09:48:07 +0300 Franz Sirl wrote: > At 17:49 03.06.2002, Michael Veksler wrote: > >If the decision will be to keep the current behavior, documentation > > should be updated. It should be more clear that -float-store is > > critical for IEEE > > conformance on targets like x86. Also, the bugs section should > > contain this as a known bug (and bug it is -- gcc does not > > conform to the IEEE standard on x86). > > Because GCC does not mess with the settings of the CPU, which is > certainly _not_ GCC's job. Checkout glibc's documentation and look > at stuff like fpu_control.h and fenv.h. I totaly agree that it is not GCC's job to fiddle with the settings of the CPU. fpu_control.h took me by surprise (especially the _FPU_EXTENDED vs. _FPU_DOUBLE macros). Do you think this is a glibc bug? In "fpu_control.h" (at least 2.2-9) it is written: /* The fdlibm code requires strict IEEE double precision arithmetic, and no interrupts for exceptions, rounding to nearest. */ And then they go on and define #define _FPU_DEFAULT 0x037f Which effectively sets rounding to _FPU_EXTENDED (=0x300), instead of double. This does seem like a glibc bug (documentation does not match reality). But, there are several open issues: 1. This should be more clearly stated in the documentation of GCC. - In the bugs section (or non-bugs, actually). Recommend to use either -float-store, or the following code: #include void set_rounding_to_double() { fpu_control_t fpu_bits; _FPU_GETCW(fpu_bits); fpu_bits &= ~_FPU_EXTENDED; fpu_bits |= _FPU_DOUBLE; _FPU_SETCW(fpu_bits); } - In gcc --help (on -float-store) 2. The _FPU_* macros are not documented in the "man" pages, nor in the info (the only reference to them is in g77.info) I still get the feeling that GCC douesthe wrong thing here. Are there no opcodes for "divide and round to double", and for "compare as double" ? I think that GCC should minimize its dependency on the "correctness" of CPU settings. This of course, only if that does not change code size, and does not hurt performance.