[Bug target/36780] [4.3/4.4 Regression] Wrong reload generated for subreg address on SH
--- Comment #5 from jsm28 at gcc dot gnu dot org 2008-07-19 11:15 --- Subject: Bug 36780 Author: jsm28 Date: Sat Jul 19 11:14:13 2008 New Revision: 137976 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=137976 Log: PR target/36780 PR target/36827 * reload.c (find_reloads_subreg_address): Only reload address if reloaded == 0, not for reloaded != 1. Revert: 2008-07-16 Joseph Myers [EMAIL PROTECTED] * config/m32c/m32c.c (BIG_FB_ADJ): Move definition earlier. (m32c_legitimate_address_p): Handle ++rii addresses created by m32c_legitimize_reload_address. 2008-07-15 Kaz Kojima [EMAIL PROTECTED] * config/sh/sh.h (GO_IF_LEGITIMATE_ADDRESS): Allow (plus (plus (reg) (const_int)) (const_int)) when reload_in_progress. Modified: trunk/gcc/ChangeLog trunk/gcc/config/m32c/m32c.c trunk/gcc/config/sh/sh.h trunk/gcc/reload.c -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36780
[Bug target/36780] [4.3/4.4 Regression] Wrong reload generated for subreg address on SH
--- Comment #6 from jsm28 at gcc dot gnu dot org 2008-07-19 11:16 --- Subject: Bug 36780 Author: jsm28 Date: Sat Jul 19 11:15:29 2008 New Revision: 137977 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=137977 Log: PR target/36780 PR target/36827 * reload.c (find_reloads_subreg_address): Only reload address if reloaded == 0, not for reloaded != 1. Revert: 2008-07-16 Joseph Myers [EMAIL PROTECTED] * config/m32c/m32c.c (BIG_FB_ADJ): Move definition earlier. (m32c_legitimate_address_p): Handle ++rii addresses created by m32c_legitimize_reload_address. 2008-07-15 Kaz Kojima [EMAIL PROTECTED] * config/sh/sh.h (GO_IF_LEGITIMATE_ADDRESS): Allow (plus (plus (reg) (const_int)) (const_int)) when reload_in_progress. Modified: branches/gcc-4_3-branch/gcc/ChangeLog branches/gcc-4_3-branch/gcc/config/m32c/m32c.c branches/gcc-4_3-branch/gcc/config/sh/sh.h branches/gcc-4_3-branch/gcc/reload.c -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36780
[Bug target/36780] [4.3/4.4 Regression] Wrong reload generated for subreg address on SH
--- Comment #7 from kkojima at gcc dot gnu dot org 2008-07-19 22:05 --- Thanks for your patch, Joseph! Fixed. -- kkojima at gcc dot gnu dot org changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution||FIXED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36780
[Bug target/36780] [4.3/4.4 Regression] Wrong reload generated for subreg address on SH
--- Comment #3 from kkojima at gcc dot gnu dot org 2008-07-15 13:07 --- Subject: Bug 36780 Author: kkojima Date: Tue Jul 15 13:06:32 2008 New Revision: 137838 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=137838 Log: PR target/36780 * config/sh/sh.h (GO_IF_LEGITIMATE_ADDRESS): Allow (plus (plus (reg) (const_int)) (const_int)) when reload_in_progress. Modified: trunk/gcc/ChangeLog trunk/gcc/config/sh/sh.h -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36780
[Bug target/36780] [4.3/4.4 Regression] Wrong reload generated for subreg address on SH
--- Comment #4 from kkojima at gcc dot gnu dot org 2008-07-15 13:18 --- Subject: Bug 36780 Author: kkojima Date: Tue Jul 15 13:17:39 2008 New Revision: 137839 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=137839 Log: Backport from mainline: PR target/36780 * config/sh/sh.h (GO_IF_LEGITIMATE_ADDRESS): Allow (plus (plus (reg) (const_int)) (const_int)) when reload_in_progress. Modified: branches/gcc-4_3-branch/gcc/ChangeLog branches/gcc-4_3-branch/gcc/config/sh/sh.h -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36780
[Bug target/36780] [4.3/4.4 Regression] Wrong reload generated for subreg address on SH
-- rguenth at gcc dot gnu dot org changed: What|Removed |Added Target Milestone|--- |4.3.2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36780
[Bug target/36780] [4.3/4.4 Regression] Wrong reload generated for subreg address on SH
-- rguenth at gcc dot gnu dot org changed: What|Removed |Added Priority|P3 |P4 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36780
[Bug target/36780] [4.3/4.4 Regression] Wrong reload generated for subreg address on SH
-- pinskia at gcc dot gnu dot org changed: What|Removed |Added CC||pinskia at gcc dot gnu dot ||org, jsm28 at gcc dot gnu ||dot org Severity|normal |major http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36780
[Bug target/36780] [4.3/4.4 Regression] Wrong reload generated for subreg address on SH
--- Comment #2 from kkojima at gcc dot gnu dot org 2008-07-10 23:25 --- First I've modified addsi3 pattern and added a splitter (define_split [(set (match_operand:SI 0 arith_reg_dest ) (plus:SI (match_operand:SI 1 arith_operand ) (match_operand:SI 2 arith_operand )))] TARGET_SH1 reload_completed !rtx_equal_p (operands[0], operands[1]) [(set (match_dup 0) (match_dup 2)) (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))] ) This fixes the build failure but there are many regressions at -O0. It seems that the reload in problem makes very complex reloads on this backend and some another latent problems are revealed. I've tried to see what is going on for these cases for a while and then given up. When looking into these complex reloads, I've noticed that the address having the type (plus (plus reg const_int) const_int) is cared about specially in LEGITIMIZE_RELOAD_ADDRESS in this backend. I've tried to add the corresponding code in GO_IF_LEGITIMATE_ADDRESS so that strict_memory_address_p can recognize the above address expression when reloading. It fixes the build failure and there are no major regressions with it. Although this is clearly a workaround and the issue should be looking more deeply, I guess this will be ok at this point, especially for the 4.3-branch which will schedule the 4.3.2 release in a month. Now I'm testing the patch below for 4.3/4.4 in native environments: --- ORIG/trunk/gcc/config/sh/sh.h 2008-07-06 09:31:18.0 +0900 +++ LOCAL/trunk/gcc/config/sh/sh.h 2008-07-10 13:58:40.0 +0900 @@ -2501,6 +2501,18 @@ struct sh_args { goto LABEL; \ } \ } \ + /* When reload in progress, find_reloads_subreg_address tries to \ + make a new reload for some types of address. Unfortunately it\ + generates wrong code on SH. See PR36780. The following is to\ + avoid this issue. */ \ + if (!TARGET_SHMEDIA reload_in_progress\ + GET_CODE (X) == PLUS \ + (GET_MODE_SIZE (MODE) == 4 || GET_MODE_SIZE (MODE) == 8) \ + GET_CODE (XEXP ((X), 0)) == PLUS \ + GET_CODE (XEXP (XEXP ((X), 0), 1)) == CONST_INT \ + BASE_REGISTER_RTX_P (XEXP (XEXP ((X), 0), 0)) \ + GET_CODE (XEXP ((X), 1)) == CONST_INT) \ +goto LABEL; \ } /* Try machine-dependent ways of modifying an illegitimate address -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36780
[Bug target/36780] [4.3/4.4 Regression] Wrong reload generated for subreg address on SH
--- Comment #1 from kkojima at gcc dot gnu dot org 2008-07-10 01:27 --- Created an attachment (id=15882) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15882action=view) A reduced test case for -O0 Before r137639, the insn in problem was (insn 200 330 331 20 yyy.cc:181 (set (mem/c:SI (plus:SI (reg:SI 6 r6) (const_int 0 [0x0])) [0 D.2244+4 S8 A32]) (reg:SI 1 r1 [261])) 175 {movsi_ie} (nil)) and now the memory address is reloaded like as (insn 331 330 200 20 xxx.cc:181 (set (reg:SI 2 r2) (plus:SI (reg:SI 6 r6) (const_int 0 [0x0]))) 35 {*addsi3_compact} (nil)) (insn 200 331 332 20 xxx.cc:181 (set (mem/c:SI (reg:SI 2 r2) [0 D.2244+4 S8 A32]) (reg:SI 1 r1 [261])) 175 {movsi_ie} (nil)) but SH has no add instruction whose destination and source differs. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36780