]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[RELOAD] Don't assume subreg mem address is ok
authorAlan Modra <amodra@gmail.com>
Wed, 17 Aug 2016 22:41:22 +0000 (08:11 +0930)
committerAlan Modra <amodra@gcc.gnu.org>
Wed, 17 Aug 2016 22:41:22 +0000 (08:11 +0930)
This patch fixes a case where reload blindly assumes a subreg mem is
OK if its address has been partially reloaded by legitimize_reload_address.

PR rtl-optimization/72771
* reload.c (find_reloads): Don't assume that a subreg mem is OK
when find_reloads_toplev returns address_reloaded==-1.
(alternative_allows_const_pool_ref): Update comment.
testsuite/
* gcc.c-torture/compile/pr72771.c: New.

From-SVN: r239549

gcc/ChangeLog
gcc/reload.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr72771.c [new file with mode: 0644]

index 6f6314671aa398214a7bcddc787a5bdf129d1222..e09cdeafe6b3290445017ce81e43a3b6cdc2a72b 100644 (file)
@@ -1,3 +1,10 @@
+2016-08-18  Alan Modra  <amodra@gmail.com>
+
+       PR rtl-optimization/72771
+       * reload.c (find_reloads): Don't assume that a subreg mem is OK
+       when find_reloads_toplev returns address_reloaded==-1.
+       (alternative_allows_const_pool_ref): Update comment.
+
 2015-08-17  Alan Hayward <alan.hayward@arm.com>
 
        PR tree-optimization/71752
index afdd56dfeca86ce35b0e96b2c29f2ed8e4e2f651..cd0d661e2246b75f030b187bd1284e7b54466657 100644 (file)
@@ -3961,7 +3961,7 @@ find_reloads (rtx_insn *insn, int replace, int ind_levels, int live_known,
               there will be no reload needed at all.  */
            if (plus == NULL_RTX
                && subreg == NULL_RTX
-               && alternative_allows_const_pool_ref (this_address_reloaded == 0
+               && alternative_allows_const_pool_ref (this_address_reloaded != 1
                                                      ? substed_operand[i]
                                                      : NULL,
                                                      recog_data.constraints[i],
@@ -4606,8 +4606,8 @@ find_reloads (rtx_insn *insn, int replace, int ind_levels, int live_known,
 
 /* Return true if alternative number ALTNUM in constraint-string
    CONSTRAINT is guaranteed to accept a reloaded constant-pool reference.
-   MEM gives the reference if it didn't need any reloads, otherwise it
-   is null.  */
+   MEM gives the reference if its address hasn't been fully reloaded,
+   otherwise it is NULL.  */
 
 static bool
 alternative_allows_const_pool_ref (rtx mem ATTRIBUTE_UNUSED,
index f1a0fa86c34a5ca485105f32d1cd197a014c8e71..4c7e6091a49e9571ff0df0dbd60aa6da5ad2d44d 100644 (file)
@@ -1,3 +1,7 @@
+2016-08-18  Alan Modra  <amodra@gmail.com>
+
+       * gcc.c-torture/compile/pr72771.c: New.
+
 2016-08-17  Jakub Jelinek  <jakub@redhat.com>
 
        PR fortran/67496
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr72771.c b/gcc/testsuite/gcc.c-torture/compile/pr72771.c
new file mode 100644 (file)
index 0000000..1cc13e3
--- /dev/null
@@ -0,0 +1,29 @@
+void fn2(void);
+void fn3(unsigned long);
+
+signed char a;
+int b, c, e, f;
+float *d;
+
+void fn1(void) {
+        unsigned short g = 0;
+lbl_986:
+        for (;;) {
+                c = 0;
+                for (; c <= 2;) {
+                        *d = g;
+                        fn2();
+                        if (e)
+                                goto lbl_986;
+                }
+                g = 2;
+                for (; (short) g >= 0; g--) {
+                        for (; b;) {
+                                fn3(45360);
+                                f = 0;
+                                for (; a >= 0; a--)
+                                        ;
+                        }
+                }
+        }
+}