This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Load motion vs. -ffloat-store
- From: Richard Sandiford <rsandifo at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: 29 Mar 2003 10:59:25 +0000
- Subject: Load motion vs. -ffloat-store
The attached test case is taken from ieee/20010114-1.c but makes
'x' a global variable rather than a parameter. It fails on
i686-pc-linux-gnu at -O2 and above.
The problem is that the accesses to 'x' are now simple enough to be
subjected to load motion [*]. After gcse, we end up with one load of
'x' at the beginning of rintf() and one store at the end. Presumably
we shouldn't do be doing this when -ffloat-store is in effect.
Patch bootstrapped & regression tested on i686-pc-linux-gnu.
OK to install?
Richard
[*] I guess the accesses in 20010114-1.c ought to be simple enough too,
but that's for a follow-on message.
* gcse.c (simple_mem): Return false for floating-point accesses
if flag_float_store is true.
testsuite/
* gcc.c-torture/execute/ieee/20030329-1.c: New test.
Index: gcse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcse.c,v
retrieving revision 1.239
diff -c -d -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.239 gcse.c
*** gcse.c 8 Mar 2003 09:47:28 -0000 1.239
--- gcse.c 29 Mar 2003 10:20:28 -0000
*************** simple_mem (x)
*** 6637,6642 ****
--- 6637,6645 ----
return 0;
if (GET_MODE (x) == BLKmode)
+ return 0;
+
+ if (flag_float_store && FLOAT_MODE_P (GET_MODE (x)))
return 0;
if (!rtx_varies_p (XEXP (x, 0), 0))
*** /dev/null Thu Aug 30 13:30:55 2001
--- testsuite/gcc.c-torture/execute/ieee/20030329-1.c Fri Mar 28 13:00:57 2003
***************
*** 0 ****
--- 1,32 ----
+ extern void exit (int);
+ extern void abort (void);
+ float x = -1.5f;
+
+ float
+ rintf ()
+ {
+ static const float TWO23 = 8388608.0;
+
+ if (__builtin_fabs (x) < TWO23)
+ {
+ if (x > 0.0)
+ {
+ x += TWO23;
+ x -= TWO23;
+ }
+ else if (x < 0.0)
+ {
+ x = TWO23 - x;
+ x = -(x - TWO23);
+ }
+ }
+
+ return x;
+ }
+
+ int main (void)
+ {
+ if (rintf () != -2.0)
+ abort ();
+ exit (0);
+ }