]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR rtl-optimization/13472 (optimizer generates code to store data in const int...
authorGabriel Dos Reis <gdr@integrable-solutions.net>
Sat, 13 Mar 2004 00:30:53 +0000 (00:30 +0000)
committerGabriel Dos Reis <gdr@gcc.gnu.org>
Sat, 13 Mar 2004 00:30:53 +0000 (00:30 +0000)
        Endorse:
        2004-01-10  Eric Botcazou  <ebotcazou@libertysurf.fr>
        PR optimization/13472
        * reload.c (reload): Don't record unchanging memory locations.

From-SVN: r79421

gcc/ChangeLog
gcc/reload1.c
gcc/testsuite/gcc.dg/const-1.c [new file with mode: 0644]

index aa6bd0a2f83b44f9927cdf9cc469415182a18b75..6583ae2246f0f099ea210496c64435a33528b35f 100644 (file)
@@ -1,3 +1,10 @@
+2004-03-12  Gabriel Dos Reis  <gdr@integrable-solutions.net>
+        
+        Endorse:
+       2004-01-10  Eric Botcazou  <ebotcazou@libertysurf.fr>
+       PR optimization/13472
+       * reload.c (reload): Don't record unchanging memory locations.
+
 2004-03-12  Gabriel Dos Reis  <gdr@integrable-solutions.net>
 
        Backport
index edab53a0e85a786c5b0fc755684028133fb58d2d..c747ddf7297dff8fe531314994363be52820eefb 100644 (file)
@@ -789,8 +789,18 @@ reload (first, global)
                     that is not a legitimate memory operand.  As later
                     stages of reload assume that all addresses found
                     in the reg_equiv_* arrays were originally legitimate,
-                    we ignore such REG_EQUIV notes.  */
-                 if (memory_operand (x, VOIDmode))
+                    we ignore such REG_EQUIV notes.
+
+                    It also can happen that a REG_EQUIV note contains a MEM
+                    that carries the /u flag, for example when GCSE turns
+                    the load of a constant into a move from a pseudo that
+                    already contains the constant and attaches a REG_EQUAL
+                    note to the insn, which is later promoted to REQ_EQUIV
+                    by local-alloc.  If the destination pseudo happens not
+                    to be assigned to a hard reg, it will be replaced by
+                    the MEM as the destination of the move, thus generating
+                    a store to a possibly read-only memory location.  */
+                 if (memory_operand (x, VOIDmode) && ! RTX_UNCHANGING_P (x))
                    {
                      /* Always unshare the equivalence, so we can
                         substitute into this insn without touching the
diff --git a/gcc/testsuite/gcc.dg/const-1.c b/gcc/testsuite/gcc.dg/const-1.c
new file mode 100644 (file)
index 0000000..40678c6
--- /dev/null
@@ -0,0 +1,56 @@
+/* PR optimization/13472 */
+/* Origin: <p.van-hoof@qub.ac.uk> */
+
+/* Verify that the reload pass doesn't emit a store
+   to the .rodata section. */
+
+/* { dg-do run } */
+/* { dg-options "-O2 -pedantic -march=i686" { target i686-*-* } } */
+
+
+#define MAX2(a,b) (((a)>(b)) ? (a) : (b))
+
+const int q=0, p=0;
+
+typedef struct {
+       float a;
+       float b;
+} F;
+
+F **E, *D, C = { 2.f, 1.f };
+
+void G(float);
+void H(void);
+
+int main(void)
+{
+       D = &C;
+       E = &D;
+
+       H();
+        return 0;
+}
+
+void H(void)
+{
+       int i, l=1;
+       float b, o;
+
+       if( l )
+       {
+               b = 0.3f * MAX2(0.f,E[q][p].a - E[q][p].b);
+               o = E[q][p].a;
+               if( o > 1.e-36f )
+                        G(o);
+               E[q][p].a *= b;
+       }
+       else
+               b = 1.f;
+       for( i=q; i<2; ++i )
+               ;
+}
+
+void G(float o)
+{
+}
+