* [PATCH/RFA] PR target/13250 @ 2004-05-28 7:09 Kaz Kojima 2004-05-28 10:12 ` Alexandre Oliva 2004-05-28 15:05 ` Joern Rennecke 0 siblings, 2 replies; 16+ messages in thread From: Kaz Kojima @ 2004-05-28 7:09 UTC (permalink / raw) To: gcc-patches; +Cc: joern.rennecke, aoliva Hi, It seems that PR target/13250 <URL:http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13250> is a problem caused by a direct substitution operands[1] for parts[?] in rotlsi3 expand of SH. The appended patch fixes it. It's tested with bootstrap 3.4 on sh4-unknown-linux-gnu and regtested on mainline for x86 cross to sh4-unknown-linux-gnu, though now mainline fails in building c++ library for this target without -fno-schedule-insns. Regards, kaz -- PR target/13250 * config/sh/sh.md (rotlsi3): Use emit_move_insn. diff -uprN ORIG/gcc/gcc/config/sh/sh.md LOCAL/gcc/gcc/config/sh/sh.md --- ORIG/gcc/gcc/config/sh/sh.md 2004-05-14 10:08:34.000000000 +0900 +++ LOCAL/gcc/gcc/config/sh/sh.md 2004-05-27 08:32:37.000000000 +0900 @@ -2194,7 +2194,7 @@ parts[0] = gen_reg_rtx (SImode); parts[1] = gen_reg_rtx (SImode); emit_insn (gen_rotlsi3_16 (parts[2-choice], operands[1])); - parts[choice-1] = operands[1]; + emit_move_insn (parts[choice-1], operands[1]); emit_insn (gen_ashlsi3 (parts[0], parts[0], GEN_INT (8))); emit_insn (gen_lshrsi3 (parts[1], parts[1], GEN_INT (8))); emit_insn (gen_iorsi3 (operands[0], parts[0], parts[1])); ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH/RFA] PR target/13250 2004-05-28 7:09 [PATCH/RFA] PR target/13250 Kaz Kojima @ 2004-05-28 10:12 ` Alexandre Oliva 2004-05-28 11:01 ` Kaz Kojima 2004-05-28 15:05 ` Joern Rennecke 1 sibling, 1 reply; 16+ messages in thread From: Alexandre Oliva @ 2004-05-28 10:12 UTC (permalink / raw) To: Kaz Kojima; +Cc: gcc-patches, joern.rennecke On May 28, 2004, Kaz Kojima <kkojima@rr.iij4u.or.jp> wrote: > PR target/13250 > * config/sh/sh.md (rotlsi3): Use emit_move_insn. Ok, thanks. -- Alexandre Oliva http://www.ic.unicamp.br/~oliva/ Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org} Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org} ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH/RFA] PR target/13250 2004-05-28 10:12 ` Alexandre Oliva @ 2004-05-28 11:01 ` Kaz Kojima 2004-05-28 14:23 ` Gabriel Dos Reis 0 siblings, 1 reply; 16+ messages in thread From: Kaz Kojima @ 2004-05-28 11:01 UTC (permalink / raw) To: aoliva; +Cc: Gabriel Dos Reis, Mark Mitchell, joern.rennecke, gcc-patches Alexandre Oliva <aoliva@redhat.com> wrote: >> PR target/13250 >> * config/sh/sh.md (rotlsi3): Use emit_move_insn. > > Ok, thanks. Thanks! Applied to mainline. This PR is originally against 3.3/3.4. Mark, is it ok for 3.4? Bootstrap and regression test is done already on 3.4-branch. Gaby, can I queue it for 3.3.5 if the tests with it is done successfully on 3.3? Regards, kaz ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH/RFA] PR target/13250 2004-05-28 11:01 ` Kaz Kojima @ 2004-05-28 14:23 ` Gabriel Dos Reis 0 siblings, 0 replies; 16+ messages in thread From: Gabriel Dos Reis @ 2004-05-28 14:23 UTC (permalink / raw) To: Kaz Kojima; +Cc: aoliva, Mark Mitchell, joern.rennecke, gcc-patches Kaz Kojima <kkojima@rr.iij4u.or.jp> writes: | Alexandre Oliva <aoliva@redhat.com> wrote: | >> PR target/13250 | >> * config/sh/sh.md (rotlsi3): Use emit_move_insn. | > | > Ok, thanks. | | Thanks! Applied to mainline. | | This PR is originally against 3.3/3.4. Mark, is it ok for 3.4? | Bootstrap and regression test is done already on 3.4-branch. | | Gaby, can I queue it for 3.3.5 if the tests with it is done | successfully on 3.3? If it goes into 3.4.x, yes. -- Gaby ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH/RFA] PR target/13250 2004-05-28 7:09 [PATCH/RFA] PR target/13250 Kaz Kojima 2004-05-28 10:12 ` Alexandre Oliva @ 2004-05-28 15:05 ` Joern Rennecke 2004-05-28 15:45 ` Kaz Kojima 1 sibling, 1 reply; 16+ messages in thread From: Joern Rennecke @ 2004-05-28 15:05 UTC (permalink / raw) To: Kaz Kojima; +Cc: gcc-patches, joern.rennecke, aoliva > It's tested with bootstrap 3.4 on sh4-unknown-linux-gnu and regtested > on mainline for x86 cross to sh4-unknown-linux-gnu, though now mainline > fails in building c++ library for this target without -fno-schedule-insns. Strange, are you saying it worked before? sh-elf has failed to build in mailine for the past two weeks. See http://gcc.gnu.org/ml/gcc-patches/2004-05/msg00857.html ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH/RFA] PR target/13250 2004-05-28 15:05 ` Joern Rennecke @ 2004-05-28 15:45 ` Kaz Kojima 2004-05-28 20:18 ` Joern Rennecke 0 siblings, 1 reply; 16+ messages in thread From: Kaz Kojima @ 2004-05-28 15:45 UTC (permalink / raw) To: joern.rennecke; +Cc: gcc-patches, aoliva Joern Rennecke <joern.rennecke@superh.com> wrote: >> It's tested with bootstrap 3.4 on sh4-unknown-linux-gnu and regtested >> on mainline for x86 cross to sh4-unknown-linux-gnu, though now mainline >> fails in building c++ library for this target without -fno-schedule-insns. > > Strange, are you saying it worked before? sh-elf has failed to build > in mailine for the past two weeks. > See http://gcc.gnu.org/ml/gcc-patches/2004-05/msg00857.html I mean that -fno-schedule-insns is needed to build c++ library on mainline. ATM, there are many spill failures in building c++ and java library for sh4-unknown-linux-gnu. Your patch for post-call group sheduling fixes all of them except a failure compiling local-inst.cc for -fPIC. Regards, kaz ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH/RFA] PR target/13250 2004-05-28 15:45 ` Kaz Kojima @ 2004-05-28 20:18 ` Joern Rennecke 2004-05-29 16:53 ` Kaz Kojima 0 siblings, 1 reply; 16+ messages in thread From: Joern Rennecke @ 2004-05-28 20:18 UTC (permalink / raw) To: Kaz Kojima; +Cc: joern.rennecke, gcc-patches, aoliva > Your patch for post-call group sheduling fixes all of them except > a failure compiling local-inst.cc for -fPIC. Thanks for the testcase (sent off-list). It turns out that the loop optimizer has inserted a jump between the call and the instruction that copied the return value. I.e. before loop2 we have: (call_insn 2975 2974 3094 88 (parallel [ (set (reg:SI 0 r0) (call (mem:SI (symbol_ref:SI ("_ZNKSt6locale2id5_M_idEv") [flags 0x41] <function_decl 0x408077b4 _M_id>) [0 S4 A32]) (const_int 0 [0x0]))) (use (reg:PSI 151 )) (use (reg:SI 12 r12)) (clobber (reg:SI 146 pr)) (clobber (scratch:SI)) ]) 172 {call_value_pcrel} (nil) (expr_list:REG_EH_REGION (const_int 1 [0x1]) (nil)) (expr_list (use (reg:SI 4 r4)) (nil))) ;; End of basic block 88, registers live: (nil) ;; Start of basic block 89, registers live: (nil) (note 3094 2975 2976 89 [bb 89] NOTE_INSN_BASIC_BLOCK) (insn 2976 3094 2978 89 (set (reg:SI 182 [ T.678 ]) (reg:SI 0 r0)) 123 {movsi_ie} (nil) (nil)) and after loop2 we got: (call_insn 2975 2974 3463 90 (parallel [ (set (reg:SI 0 r0) (call (mem:SI (symbol_ref:SI ("_ZNKSt6locale2id5_M_idEv") [flags 0x41] <function_decl 0x408077b4 _M_id>) [0 S4 A32]) (const_int 0 [0x0]))) (use (reg:PSI 151 )) (use (reg:SI 12 r12)) (clobber (reg:SI 146 pr)) (clobber (scratch:SI)) ]) 172 {call_value_pcrel} (nil) (expr_list:REG_EH_REGION (const_int 1 [0x1]) (nil)) (expr_list (use (reg:SI 4 r4)) (nil))) ;; End of basic block 90, registers live: (nil) ;; Start of basic block 91, registers live: (nil) (note 3463 2975 3465 91 [bb 91] NOTE_INSN_BASIC_BLOCK) (jump_insn 3465 3463 3466 91 (set (pc) (label_ref 3464)) -1 (nil) (nil)) ;; End of basic block 91, registers live: (nil) (barrier 3466 3465 3250) ;; Start of basic block 92, registers live: (nil) (code_label/s 3250 3466 3253 92 352 "" [1 uses]) (note 3253 3250 3251 92 [bb 92] NOTE_INSN_BASIC_BLOCK) (insn 3251 3253 3252 92 (set (reg:SI 374 [ save_eptr.1036 ]) (reg:SI 4 r4)) 123 {movsi_ie} (nil) (nil)) (insn 3252 3251 3097 92 (set (reg:SI 373 [ save_filt.1037 ]) (reg:SI 5 r5)) 123 {movsi_ie} (nil) (nil)) ;; End of basic block 92, registers live: (nil) ;; Start of basic block 93, registers live: (nil) (code_label 3097 3252 3102 93 327 "" [16 uses]) (note 3102 3097 3098 93 [bb 93] NOTE_INSN_BASIC_BLOCK) (insn 3098 3102 3099 93 (set (reg:SI 147 t) (eq:SI (reg:SI 373 [ save_filt.1037 ]) (const_int -1 [0xffffffff]))) 1 {cmpeqsi_t} (nil) (nil)) (jump_insn 3099 3098 3254 93 (set (pc) (if_then_else (ne (reg:SI 147 t) (const_int 0 [0x0])) (label_ref 2987) (pc))) 153 {branch_true} (nil) (expr_list:REG_BR_PROB (const_int 2901 [0xb55]) (nil))) ;; End of basic block 93, registers live: (nil) ;; Start of basic block 94, registers live: (nil) (note 3254 3099 3151 94 [bb 94] NOTE_INSN_BASIC_BLOCK) (insn 3151 3254 3152 94 (set (reg:SI 4 r4 [ save_eptr.1036 ]) (reg:SI 374 [ save_eptr.1036 ])) 123 {movsi_ie} (nil) (nil)) (call_insn 3152 3151 3101 94 (parallel [ (call (mem:SI (symbol_ref:SI ("_Unwind_Resume") [flags 0x41]) [0 S4 A32]) (const_int 0 [0x0])) (use (reg:PSI 151 )) (use (reg:SI 12 r12)) (clobber (reg:SI 146 pr)) (clobber (scratch:SI)) ]) 166 {call_pcrel} (nil) (expr_list:REG_NORETURN (const_int 0 [0x0]) (nil)) (expr_list (use (reg:SI 4 r4 [ save_eptr.1036 ])) (nil))) ;; End of basic block 94, registers live: (nil) (barrier 3101 3152 2987) ;; Start of basic block 95, registers live: (nil) (code_label/s 2987 3101 3095 95 326 "" [2 uses]) (note 3095 2987 2990 95 [bb 95] NOTE_INSN_BASIC_BLOCK) (insn 2990 3095 2991 95 (set (reg:SI 4 r4 [ save_eptr.1036 ]) (reg:SI 374 [ save_eptr.1036 ])) 123 {movsi_ie} (nil) (nil)) (call_insn 2991 2990 2992 95 (parallel [ (call (mem:SI (symbol_ref:SI ("__cxa_call_unexpected") [flags 0x41] <function_decl 0x402ac740 __cxa_call_unexpected>) [0 S4 A32]) (const_int 0 [0x0])) (use (reg:PSI 151 )) (use (reg:SI 12 r12)) (clobber (reg:SI 146 pr)) (clobber (scratch:SI)) ]) 166 {call_pcrel} (nil) (expr_list:REG_NORETURN (const_int 0 [0x0]) (nil)) (expr_list (use (reg:SI 4 r4 [ save_eptr.1036 ])) (nil))) ;; End of basic block 95, registers live: (nil) (barrier 2992 2991 3464) ;; Start of basic block 96, registers live: (nil) (code_label 3464 2992 3094 96 373 "" [1 uses]) (note 3094 3464 2976 96 [bb 96] NOTE_INSN_BASIC_BLOCK) (insn 2976 3094 2978 96 (set (reg:SI 182 [ T.678 ]) (reg:SI 0 r0)) 123 {movsi_ie} (nil) (nil)) This in itself doesn't cause a reload problem, but it means that we have to look harder to find out if we got a post-call group. I must admit that I'm at a bit of a loss what the point of the reordering is. Unfortunately, the new cfg handling makes it harder to track down changes to the code that cause them. #0 make_jump_insn_raw (pattern=0x401d8340) at ../../srcw/gcc/emit-rtl.c:3439 #1 0x08365a7b in emit_jump_insn (x=0x401d8340) at ../../srcw/gcc/emit-rtl.c:4548 #2 0x08464794 in gen_jump (operand0=0x40d0191c) at insn-emit.c:9990 #3 0x08309be0 in force_nonfallthru_and_redirect (e=0x40ca3ef4, target=0x406ffef4) at ../../srcw/gcc/cfgrtl.c:1142 #4 0x08309c63 in force_nonfallthru (e=0x40ca3ef4) at ../../srcw/gcc/cfgrtl.c:1163 #5 0x08300637 in fixup_reorder_chain () at ../../srcw/gcc/cfglayout.c:778 #6 0x083012ca in cfg_layout_finalize () at ../../srcw/gcc/cfglayout.c:1180 #7 0x085c6859 in rest_of_handle_loop2 (decl=0x4080fb54, insns=0x4077f168) at ../../srcw/gcc/passes.c:1337 At any rate, this is how this can be fixed in sched-deps too: 2004-05-28 J"orn Rennecke <joern.rennecke@superh.com> * sched-int.h (in_post_call_group_p): Change type to enum. * sched-deps.c (sched_analyze_insn): (sched_analyze): When in_post_call_group_p is post_call_initial, don't add a dependency, but still set SCHED_GROUP_P and CANT_MOVE, and also reset in_post_call_group_p to post_call. (sched_analyze): When the previous basic block ended in a CALL_INSN, initialize in_post_call_group_p as post_call_initial. (init_deps): initialize in_post_call_group_p to not_post_call. Index: sched-deps.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/sched-deps.c,v retrieving revision 1.72 diff -p -r1.72 sched-deps.c *** sched-deps.c 25 Mar 2004 00:58:57 -0000 1.72 --- sched-deps.c 28 May 2004 17:45:49 -0000 *************** sched_analyze_insn (struct deps *deps, r *** 1145,1157 **** if (src_regno < FIRST_PSEUDO_REGISTER || dest_regno < FIRST_PSEUDO_REGISTER) { ! set_sched_group_p (insn); CANT_MOVE (insn) = 1; } else { end_call_group: ! deps->in_post_call_group_p = false; } } } --- 1145,1165 ---- if (src_regno < FIRST_PSEUDO_REGISTER || dest_regno < FIRST_PSEUDO_REGISTER) { ! /* If we are inside a post-call group right at the start of the ! scheduling region, we must not add a dependency. */ ! if (deps->in_post_call_group_p == post_call_initial) ! { ! SCHED_GROUP_P (insn) = 1; ! deps->in_post_call_group_p = post_call; ! } ! else ! set_sched_group_p (insn); CANT_MOVE (insn) = 1; } else { end_call_group: ! deps->in_post_call_group_p = not_post_call; } } } *************** sched_analyze (struct deps *deps, rtx he *** 1168,1173 **** --- 1176,1213 ---- if (current_sched_info->use_cselib) cselib_init (true); + /* Before reload, if the previous block ended in a call, show that + we are inside a post-call group, so as to keep the lifetimes of + hard registers correct. */ + if (! reload_completed) + { + insn = prev_nonnote_insn (head); + if (insn && GET_CODE (insn) != CODE_LABEL) + { + if (insn && GET_CODE (insn) == CALL_INSN) + deps->in_post_call_group_p = post_call_initial; + } + else if (insn) + { + /* The new loop optimizer can insert jumps in strange places - + between a call and the insn that copies the return value. + This is in itself harmless, but makes it harder here to + recognize post-call groups. */ + edge e; + basic_block pred_bb; + + for (e = BLOCK_FOR_INSN (head)->pred; e; e = e->pred_next) + { + pred_bb = e->src; + insn = BB_END(pred_bb); + if (GET_CODE (insn) != JUMP_INSN) + continue; + insn = prev_nonnote_insn (insn); + if (insn && GET_CODE (insn) == CALL_INSN) + deps->in_post_call_group_p = post_call_initial; + } + } + } for (insn = head;; insn = NEXT_INSN (insn)) { rtx link, end_seq, r0, set; *************** sched_analyze (struct deps *deps, rtx he *** 1259,1265 **** /* Before reload, begin a post-call group, so as to keep the lifetimes of hard registers correct. */ if (! reload_completed) ! deps->in_post_call_group_p = true; } /* See comments on reemit_notes as to why we do this. --- 1299,1305 ---- /* Before reload, begin a post-call group, so as to keep the lifetimes of hard registers correct. */ if (! reload_completed) ! deps->in_post_call_group_p = post_call; } /* See comments on reemit_notes as to why we do this. *************** init_deps (struct deps *deps) *** 1420,1426 **** deps->last_pending_memory_flush = 0; deps->last_function_call = 0; deps->sched_before_next_call = 0; ! deps->in_post_call_group_p = false; deps->libcall_block_tail_insn = 0; } --- 1460,1466 ---- deps->last_pending_memory_flush = 0; deps->last_function_call = 0; deps->sched_before_next_call = 0; ! deps->in_post_call_group_p = not_post_call; deps->libcall_block_tail_insn = 0; } ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH/RFA] PR target/13250 2004-05-28 20:18 ` Joern Rennecke @ 2004-05-29 16:53 ` Kaz Kojima 2004-06-01 12:19 ` Joern Rennecke 0 siblings, 1 reply; 16+ messages in thread From: Kaz Kojima @ 2004-05-29 16:53 UTC (permalink / raw) To: joern.rennecke; +Cc: gcc-patches, aoliva Joern Rennecke <joern.rennecke@superh.com> wrote: > It turns out that the loop optimizer has inserted a jump between > the call and the instruction that copied the return value. [snip] > At any rate, this is how this can be fixed in sched-deps too: All libraries are successfully built on mainline with your new patch for sh4-unknown-linux-gnu! I saw compiler segfaults in patch for some C tests because BB_END returns a null for those cases. Changing a line like + if (! insn || GET_CODE (insn) != JUMP_INSN) + continue; seems work for me and cross building and C regression test are ok with it. The result of C++ test is same as one without patch but with libstdc++.so built with -fno-schedule-insns. I've tested it with i686-pc-linux-gnu bootstrap and regtest. Now full bootstrap on sh4-unknown-linux-gnu goes on. Regards, kaz ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH/RFA] PR target/13250 2004-05-29 16:53 ` Kaz Kojima @ 2004-06-01 12:19 ` Joern Rennecke 2004-06-01 12:46 ` Kaz Kojima 0 siblings, 1 reply; 16+ messages in thread From: Joern Rennecke @ 2004-06-01 12:19 UTC (permalink / raw) To: Kaz Kojima; +Cc: joern.rennecke, gcc-patches, aoliva > > Joern Rennecke <joern.rennecke@superh.com> wrote: > > It turns out that the loop optimizer has inserted a jump between > > the call and the instruction that copied the return value. > [snip] > > At any rate, this is how this can be fixed in sched-deps too: > > All libraries are successfully built on mainline with your new > patch for sh4-unknown-linux-gnu! > I saw compiler segfaults in patch for some C tests because > BB_END returns a null for those cases. Changing a line like > > + if (! insn || GET_CODE (insn) != JUMP_INSN) > + continue; I don't think that should ever happen. Even when we have a syntax error code is either emitted or it isn't. The basic block structures are created for the instructions that are actually present. Which testcases demonstrate this problem? ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH/RFA] PR target/13250 2004-06-01 12:19 ` Joern Rennecke @ 2004-06-01 12:46 ` Kaz Kojima 2004-06-02 16:42 ` Joern Rennecke 0 siblings, 1 reply; 16+ messages in thread From: Kaz Kojima @ 2004-06-01 12:46 UTC (permalink / raw) To: joern.rennecke; +Cc: gcc-patches, aoliva Joern Rennecke <joern.rennecke@superh.com> wrote: >> I saw compiler segfaults in patch for some C tests because >> BB_END returns a null for those cases. Changing a line like >> >> + if (! insn || GET_CODE (insn) != JUMP_INSN) >> + continue; > > I don't think that should ever happen. Even when we have a syntax > error code is either emitted or it isn't. The basic block structures > are created for the instructions that are actually present. > Which testcases demonstrate this problem? The first several testcases are gcc.c-torture/compile/20000728-1.c (-O2) gcc.c-torture/compile/20011229-2.c (-Os) gcc.c-torture/compile/20031113-1.c (-O3) gcc.c-torture/compile/920623-1.c (-O2) gcc.c-torture/compile/930210-1.c (-O2) Regards, kaz ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH/RFA] PR target/13250 2004-06-01 12:46 ` Kaz Kojima @ 2004-06-02 16:42 ` Joern Rennecke 2004-06-03 4:02 ` Kaz Kojima 0 siblings, 1 reply; 16+ messages in thread From: Joern Rennecke @ 2004-06-02 16:42 UTC (permalink / raw) To: Kaz Kojima; +Cc: joern.rennecke, gcc-patches, aoliva > gcc.c-torture/compile/20000728-1.c (-O2) It turned out that this was ENTRY_BLOCK_PTR. So that's all right then that there are no insns. This testcase works when I add: if (pred_bb == ENTRY_BLOCK_PTR) continue; ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH/RFA] PR target/13250 2004-06-02 16:42 ` Joern Rennecke @ 2004-06-03 4:02 ` Kaz Kojima 2004-06-04 14:45 ` building sh-elf / sh-linux (Was: Re: [PATCH/RFA] PR target/13250) Joern Rennecke 0 siblings, 1 reply; 16+ messages in thread From: Kaz Kojima @ 2004-06-03 4:02 UTC (permalink / raw) To: joern.rennecke; +Cc: gcc-patches, aoliva Joern Rennecke <joern.rennecke@superh.com> wrote: >> gcc.c-torture/compile/20000728-1.c (-O2) > > It turned out that this was ENTRY_BLOCK_PTR. So that's all right then > that there are no insns. This testcase works when I add: > > if (pred_bb == ENTRY_BLOCK_PTR) > continue; It fixes all similar failures in make check-gcc on x86 cross to sh4-unknown-linux-gnu. There are no problems in building c++ and java libraries too. I'm trying to bootstrap on native i686-linux and sh4-linux with this patch. Regards, kaz ^ permalink raw reply [flat|nested] 16+ messages in thread
* building sh-elf / sh-linux (Was: Re: [PATCH/RFA] PR target/13250) 2004-06-03 4:02 ` Kaz Kojima @ 2004-06-04 14:45 ` Joern Rennecke 2004-06-07 20:48 ` Joern Rennecke 0 siblings, 1 reply; 16+ messages in thread From: Joern Rennecke @ 2004-06-04 14:45 UTC (permalink / raw) To: Kaz Kojima; +Cc: joern.rennecke, gcc-patches, aoliva I'm not really happy with having the scheduler follow through jumps to find call / call-value-copy pairs. I have now implemented the approach of deleting fixup_fallthru_exit_predecessor and making mid-function epilogues valid. There was also a real.c bug that got in the way. I'm appending the patch set that I am currently testing; I'll submit the two new patches individually when they are tested. 2004-06-04 J"orn Rennecke <joern.rennecke@superh.com> * basic-block.h (could_fall_through): Declare. * cfganal.c (can_fallthru): Suceed if the target is EXIT_BLOCK_PTR. Fail if the source already has a fallthrough edge to the exit block pointer. (could_fall_through): New function. (make_edges): Check if we already have a fallthrough edge to the exit block pointer. cfglayout.c (fixup_fallthru_exit_predecessor): Delete. (cfg_layout_finalize): Don't call it. (fixup_reorder_chain): A fall through to the exit block does not require the block to come last. Add sanity checks. * cfgrtl.c (rtl_split_edge): Add special handling of fall through edges to the exit block. 2004-06-03 J"orn Rennecke <joern.rennecke@superh.com> * real.c (do_add): Initialize r->signalling and r->canonical. 2004-05-14 J"orn Rennecke <joern.rennecke@superh.com> * sched-int.h (in_post_call_group_p): Change type to enum. * sched-deps.c (sched_analyze_insn): (sched_analyze): When in_post_call_group_p is post_call_initial, don't add a dependency, but still set SCHED_GROUP_P and CANT_MOVE, and also reset in_post_call_group_p to post_call. (sched_analyze): When the previous basic block ended in a CALL_INSN, initialize in_post_call_group_p as post_call_initial. (init_deps): initialize in_post_call_group_p to not_post_call. Index: basic-block.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/basic-block.h,v retrieving revision 1.196 diff -p -r1.196 basic-block.h *** basic-block.h 15 May 2004 09:39:28 -0000 1.196 --- basic-block.h 4 Jun 2004 14:13:14 -0000 *************** extern void find_sub_basic_blocks (basic *** 628,633 **** --- 628,634 ---- extern void find_many_sub_basic_blocks (sbitmap); extern void rtl_make_eh_edge (sbitmap *, basic_block, rtx); extern bool can_fallthru (basic_block, basic_block); + extern bool could_fall_through (basic_block, basic_block); extern void flow_nodes_print (const char *, const sbitmap, FILE *); extern void flow_edge_list_print (const char *, const edge *, int, FILE *); extern void alloc_aux_for_block (basic_block, int); Index: cfganal.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/cfganal.c,v retrieving revision 1.42 diff -p -r1.42 cfganal.c *** cfganal.c 13 May 2004 06:39:32 -0000 1.42 --- cfganal.c 4 Jun 2004 14:13:14 -0000 *************** bool *** 103,119 **** can_fallthru (basic_block src, basic_block target) { rtx insn = BB_END (src); ! rtx insn2 = target == EXIT_BLOCK_PTR ? NULL : BB_HEAD (target); if (src->next_bb != target) return 0; if (insn2 && !active_insn_p (insn2)) insn2 = next_active_insn (insn2); /* ??? Later we may add code to move jump tables offline. */ return next_active_insn (insn) == insn2; } \f /* Mark the back edges in DFS traversal. Return nonzero if a loop (natural or otherwise) is present. --- 103,144 ---- can_fallthru (basic_block src, basic_block target) { rtx insn = BB_END (src); ! rtx insn2; ! edge e; + if (target == EXIT_BLOCK_PTR) + return true; if (src->next_bb != target) return 0; + for (e = src->succ; e; e = e->succ_next) + if (e->dest == EXIT_BLOCK_PTR + && e->flags & EDGE_FALLTHRU) + return 0; + insn2 = BB_HEAD (target); if (insn2 && !active_insn_p (insn2)) insn2 = next_active_insn (insn2); /* ??? Later we may add code to move jump tables offline. */ return next_active_insn (insn) == insn2; } + + /* Return nonzero if we could reach target from src by falling through, + if the target was made adjacent. If we already have a fall-through + edge to the exit block, we can't do that. */ + bool + could_fall_through (basic_block src, basic_block target) + { + edge e; + + if (target == EXIT_BLOCK_PTR) + return true; + for (e = src->succ; e; e = e->succ_next) + if (e->dest == EXIT_BLOCK_PTR + && e->flags & EDGE_FALLTHRU) + return 0; + return true; + } \f /* Mark the back edges in DFS traversal. Return nonzero if a loop (natural or otherwise) is present. Index: cfgbuild.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/cfgbuild.c,v retrieving revision 1.46 diff -p -r1.46 cfgbuild.c *** cfgbuild.c 27 May 2004 12:56:30 -0000 1.46 --- cfgbuild.c 4 Jun 2004 14:13:14 -0000 *************** make_edges (rtx label_value_list, basic_ *** 313,318 **** --- 313,319 ---- rtx insn, x; enum rtx_code code; int force_fallthru = 0; + edge e; if (GET_CODE (BB_HEAD (bb)) == CODE_LABEL && LABEL_ALT_ENTRY_P (BB_HEAD (bb))) *************** make_edges (rtx label_value_list, basic_ *** 435,440 **** --- 436,447 ---- /* Find out if we can drop through to the next block. */ insn = NEXT_INSN (insn); + for (e = bb->succ; e; e = e->succ_next) + if (e->dest == EXIT_BLOCK_PTR && e->flags & EDGE_FALLTHRU) + { + insn = 0; + break; + } while (insn && GET_CODE (insn) == NOTE && NOTE_LINE_NUMBER (insn) != NOTE_INSN_BASIC_BLOCK) Index: cfglayout.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/cfglayout.c,v retrieving revision 1.59 diff -p -r1.59 cfglayout.c *** cfglayout.c 25 May 2004 12:54:53 -0000 1.59 --- cfglayout.c 4 Jun 2004 14:13:14 -0000 *************** static void set_block_levels (tree, int) *** 53,59 **** static void change_scope (rtx, tree, tree); void verify_insn_chain (void); - static void fixup_fallthru_exit_predecessor (void); static tree insn_scope (rtx); static void update_unlikely_executed_notes (basic_block); \f --- 53,58 ---- *************** fixup_reorder_chain (void) *** 714,719 **** --- 713,722 ---- && invert_jump (bb_end_insn, label_for_bb (e_fall->dest), 0)) { + #ifdef ENABLE_CHECKING + if (!could_fall_through (e_taken->src, e_taken->dest)) + abort (); + #endif e_fall->flags &= ~EDGE_FALLTHRU; e_taken->flags |= EDGE_FALLTHRU; update_br_prob_note (bb); *************** fixup_reorder_chain (void) *** 731,736 **** --- 734,743 ---- else if (invert_jump (bb_end_insn, label_for_bb (e_fall->dest), 0)) { + #ifdef ENABLE_CHECKING + if (!could_fall_through (e_taken->src, e_taken->dest)) + abort (); + #endif e_fall->flags &= ~EDGE_FALLTHRU; e_taken->flags |= EDGE_FALLTHRU; update_br_prob_note (bb); *************** fixup_reorder_chain (void) *** 770,776 **** continue; /* A fallthru to exit block. */ ! if (!bb->rbi->next && e_fall->dest == EXIT_BLOCK_PTR) continue; } --- 777,783 ---- continue; /* A fallthru to exit block. */ ! if (e_fall->dest == EXIT_BLOCK_PTR) continue; } *************** verify_insn_chain (void) *** 910,943 **** abort (); } \f - /* The block falling through to exit must be the last one in the - reordered chain. Ensure that this condition is met. */ - static void - fixup_fallthru_exit_predecessor (void) - { - edge e; - basic_block bb = NULL; - - for (e = EXIT_BLOCK_PTR->pred; e; e = e->pred_next) - if (e->flags & EDGE_FALLTHRU) - bb = e->src; - - if (bb && bb->rbi->next) - { - basic_block c = ENTRY_BLOCK_PTR->next_bb; - - while (c->rbi->next != bb) - c = c->rbi->next; - - c->rbi->next = bb->rbi->next; - while (c->rbi->next) - c = c->rbi->next; - - c->rbi->next = bb; - bb->rbi->next = NULL; - } - } - \f /* Return true in case it is possible to duplicate the basic block BB. */ /* We do not want to declare the function in a header file, since it should --- 917,922 ---- *************** cfg_layout_finalize (void) *** 1176,1182 **** verify_flow_info (); #endif rtl_register_cfg_hooks (); - fixup_fallthru_exit_predecessor (); fixup_reorder_chain (); #ifdef ENABLE_CHECKING --- 1155,1160 ---- Index: cfgrtl.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/cfgrtl.c,v retrieving revision 1.118 diff -p -r1.118 cfgrtl.c *** cfgrtl.c 13 May 2004 06:39:32 -0000 1.118 --- cfgrtl.c 4 Jun 2004 14:13:14 -0000 *************** rtl_split_edge (edge edge_in) *** 1337,1343 **** else before = NULL_RTX; ! bb = create_basic_block (before, NULL, edge_in->dest->prev_bb); /* ??? This info is likely going to be out of date very soon. */ if (edge_in->dest->global_live_at_start) --- 1337,1355 ---- else before = NULL_RTX; ! /* If this is a fall through edge to the exit block, the blocks might be ! not adjacent, and the right place is the after the source. */ ! if (edge_in->flags & EDGE_FALLTHRU && edge_in->dest == EXIT_BLOCK_PTR) ! { ! before = NEXT_INSN (BB_END (edge_in->src)); ! if (before ! && GET_CODE (before) == NOTE ! && NOTE_LINE_NUMBER (before) == NOTE_INSN_LOOP_END) ! before = NEXT_INSN (before); ! bb = create_basic_block (before, NULL, edge_in->src); ! } ! else ! bb = create_basic_block (before, NULL, edge_in->dest->prev_bb); /* ??? This info is likely going to be out of date very soon. */ if (edge_in->dest->global_live_at_start) Index: real.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/real.c,v retrieving revision 1.141 diff -p -r1.141 real.c *** real.c 22 Mar 2004 00:40:44 -0000 1.141 --- real.c 4 Jun 2004 14:13:15 -0000 *************** do_add (REAL_VALUE_TYPE *r, const REAL_V *** 580,585 **** --- 580,591 ---- abort (); } + /* Make sure all fields in the result are initialized. + This is needed so that tree hashing produces consistent results. + We can't use get_zero here because A or B might be equal to R. */ + r->signalling = 0; + r->canonical = 0; + /* Swap the arguments such that A has the larger exponent. */ dexp = REAL_EXP (a) - REAL_EXP (b); if (dexp < 0) Index: sched-deps.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/sched-deps.c,v retrieving revision 1.72 diff -p -r1.72 sched-deps.c *** sched-deps.c 25 Mar 2004 00:58:57 -0000 1.72 --- sched-deps.c 4 Jun 2004 14:13:15 -0000 *************** sched_analyze_insn (struct deps *deps, r *** 1145,1157 **** if (src_regno < FIRST_PSEUDO_REGISTER || dest_regno < FIRST_PSEUDO_REGISTER) { ! set_sched_group_p (insn); CANT_MOVE (insn) = 1; } else { end_call_group: ! deps->in_post_call_group_p = false; } } } --- 1145,1165 ---- if (src_regno < FIRST_PSEUDO_REGISTER || dest_regno < FIRST_PSEUDO_REGISTER) { ! /* If we are inside a post-call group right at the start of the ! scheduling region, we must not add a dependency. */ ! if (deps->in_post_call_group_p == post_call_initial) ! { ! SCHED_GROUP_P (insn) = 1; ! deps->in_post_call_group_p = post_call; ! } ! else ! set_sched_group_p (insn); CANT_MOVE (insn) = 1; } else { end_call_group: ! deps->in_post_call_group_p = not_post_call; } } } *************** sched_analyze (struct deps *deps, rtx he *** 1168,1173 **** --- 1176,1190 ---- if (current_sched_info->use_cselib) cselib_init (true); + /* Before reload, if the previous block ended in a call, show that + we are inside a post-call group, so as to keep the lifetimes of + hard registers correct. */ + if (! reload_completed && GET_CODE (head) != CODE_LABEL) + { + insn = prev_nonnote_insn (head); + if (insn && GET_CODE (insn) == CALL_INSN) + deps->in_post_call_group_p = post_call_initial; + } for (insn = head;; insn = NEXT_INSN (insn)) { rtx link, end_seq, r0, set; *************** sched_analyze (struct deps *deps, rtx he *** 1259,1265 **** /* Before reload, begin a post-call group, so as to keep the lifetimes of hard registers correct. */ if (! reload_completed) ! deps->in_post_call_group_p = true; } /* See comments on reemit_notes as to why we do this. --- 1276,1282 ---- /* Before reload, begin a post-call group, so as to keep the lifetimes of hard registers correct. */ if (! reload_completed) ! deps->in_post_call_group_p = post_call; } /* See comments on reemit_notes as to why we do this. *************** init_deps (struct deps *deps) *** 1420,1426 **** deps->last_pending_memory_flush = 0; deps->last_function_call = 0; deps->sched_before_next_call = 0; ! deps->in_post_call_group_p = false; deps->libcall_block_tail_insn = 0; } --- 1437,1443 ---- deps->last_pending_memory_flush = 0; deps->last_function_call = 0; deps->sched_before_next_call = 0; ! deps->in_post_call_group_p = not_post_call; deps->libcall_block_tail_insn = 0; } Index: sched-int.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/sched-int.h,v retrieving revision 1.32 diff -p -r1.32 sched-int.h *** sched-int.h 23 Feb 2004 17:02:50 -0000 1.32 --- sched-int.h 4 Jun 2004 14:13:15 -0000 *************** struct deps *** 84,90 **** /* Used to keep post-call pseudo/hard reg movements together with the call. */ ! bool in_post_call_group_p; /* Set to the tail insn of the outermost libcall block. --- 84,90 ---- /* Used to keep post-call pseudo/hard reg movements together with the call. */ ! enum { not_post_call, post_call, post_call_initial } in_post_call_group_p; /* Set to the tail insn of the outermost libcall block. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: building sh-elf / sh-linux (Was: Re: [PATCH/RFA] PR target/13250) 2004-06-04 14:45 ` building sh-elf / sh-linux (Was: Re: [PATCH/RFA] PR target/13250) Joern Rennecke @ 2004-06-07 20:48 ` Joern Rennecke 0 siblings, 0 replies; 16+ messages in thread From: Joern Rennecke @ 2004-06-07 20:48 UTC (permalink / raw) To: gcc-patches; +Cc: Kaz Kojima, joern.rennecke, aoliva > 2004-06-04 J"orn Rennecke <joern.rennecke@superh.com> > > * basic-block.h (could_fall_through): Declare. > * cfganal.c (can_fallthru): Suceed if the target is EXIT_BLOCK_PTR. > Fail if the source already has a fallthrough edge to the exit > block pointer. > (could_fall_through): New function. > (make_edges): Check if we already have a fallthrough edge to the > exit block pointer. > cfglayout.c (fixup_fallthru_exit_predecessor): Delete. > (cfg_layout_finalize): Don't call it. > (fixup_reorder_chain): A fall through to the exit block does not > require the block to come last. Add sanity checks. > * cfgrtl.c (rtl_split_edge): Add special handling of fall through > edges to the exit block. > > 2004-06-03 J"orn Rennecke <joern.rennecke@superh.com> > > * real.c (do_add): Initialize r->signalling and r->canonical. > > 2004-05-14 J"orn Rennecke <joern.rennecke@superh.com> > > * sched-int.h (in_post_call_group_p): Change type to enum. > * sched-deps.c (sched_analyze_insn): > (sched_analyze): When in_post_call_group_p is post_call_initial, > don't add a dependency, but still set SCHED_GROUP_P and CANT_MOVE, > and also reset in_post_call_group_p to post_call. > (sched_analyze): When the previous basic block ended in a CALL_INSN, > initialize in_post_call_group_p as post_call_initial. > (init_deps): initialize in_post_call_group_p to not_post_call. Sorry about the noise I created when trying to bootstrap with a Red Hat gcc 2.96 compiler. Using a gcc 3.0.2 bootstrap compiler, I could bootstrap both original and patched sources, and the set of regressions is also identical for both. ^ permalink raw reply [flat|nested] 16+ messages in thread
[parent not found: <no.id>]
* Re: building sh-elf / sh-linux (Was: Re: [PATCH/RFA] PR target/13250) [not found] <no.id> @ 2004-06-04 15:56 ` Joern Rennecke 2004-06-04 18:25 ` Joern Rennecke 0 siblings, 1 reply; 16+ messages in thread From: Joern Rennecke @ 2004-06-04 15:56 UTC (permalink / raw) To: renneckej; +Cc: Kaz Kojima, joern.rennecke, gcc-patches, aoliva > > I'm not really happy with having the scheduler follow through jumps to > find call / call-value-copy pairs. I have now implemented > the approach of deleting fixup_fallthru_exit_predecessor and making > mid-function epilogues valid. > There was also a real.c bug that got in the way. I'm appending the patch > set that I am currently testing; I'll submit the two new patches > individually when they are tested. > > 2004-06-04 J"orn Rennecke <joern.rennecke@superh.com> > > * basic-block.h (could_fall_through): Declare. > * cfganal.c (can_fallthru): Suceed if the target is EXIT_BLOCK_PTR. > Fail if the source already has a fallthrough edge to the exit > block pointer. > (could_fall_through): New function. > (make_edges): Check if we already have a fallthrough edge to the > exit block pointer. > cfglayout.c (fixup_fallthru_exit_predecessor): Delete. > (cfg_layout_finalize): Don't call it. > (fixup_reorder_chain): A fall through to the exit block does not > require the block to come last. Add sanity checks. > * cfgrtl.c (rtl_split_edge): Add special handling of fall through > edges to the exit block. > > 2004-06-03 J"orn Rennecke <joern.rennecke@superh.com> > > * real.c (do_add): Initialize r->signalling and r->canonical. > > 2004-05-14 J"orn Rennecke <joern.rennecke@superh.com> > > * sched-int.h (in_post_call_group_p): Change type to enum. > * sched-deps.c (sched_analyze_insn): > (sched_analyze): When in_post_call_group_p is post_call_initial, > don't add a dependency, but still set SCHED_GROUP_P and CANT_MOVE, > and also reset in_post_call_group_p to post_call. > (sched_analyze): When the previous basic block ended in a CALL_INSN, I've chosen a i686-pc-linux-gnu host for a bootstrap test. For the unmodified control, I got a failure during stage1 building crtbegin.o - cc1 throws a floating point exception. The patched compiler has moved on to stage2 in the meantime. Likewise, sh-elf (using sources from the 26th May as baseline) has suceeded building and the sh1 big endian results are: === gcc Summary for sh-hms-sim === # of expected passes 25703 # of unexpected failures 29 # of unexpected successes 1 # of expected failures 68 # of unresolved testcases 5 # of untested testcases 28 # of unsupported tests 368 Considering that the controls don't build at all, I suppose I can say the regression test passed. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: building sh-elf / sh-linux (Was: Re: [PATCH/RFA] PR target/13250) 2004-06-04 15:56 ` Joern Rennecke @ 2004-06-04 18:25 ` Joern Rennecke 0 siblings, 0 replies; 16+ messages in thread From: Joern Rennecke @ 2004-06-04 18:25 UTC (permalink / raw) To: Joern Rennecke; +Cc: Kaz Kojima, joern.rennecke, gcc-patches, aoliva, gcc > I've chosen a i686-pc-linux-gnu host for a bootstrap test. > For the unmodified control, I got a failure during stage1 building > crtbegin.o - cc1 throws a floating point exception. The patched > compiler has moved on to stage2 in the meantime. Hmm, it's actually a stage2 failure, and it is the same with and without patches. Program received signal SIGFPE, Arithmetic exception. 0x08421ace in narrow_str_to_charconst (pfile=0x8590518, str= {len = 2, text = 0x85bcc78 "\n"}, pchars_seen=0xbfffe650, unsignedp=0xbfffe654) at ../../srcw/libcpp/charset.c:1214 1214 size_t max_chars = CPP_OPTION (pfile, int_precision) / width; (gdb) p width $1 = 0 (gdb) l 1209 static cppchar_t 1210 narrow_str_to_charconst (cpp_reader *pfile, cpp_string str, 1211 unsigned int *pchars_seen, int *unsignedp) 1212 { 1213 size_t width = CPP_OPTION (pfile, char_precision); 1214 size_t max_chars = CPP_OPTION (pfile, int_precision) / width; ^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2004-06-07 20:20 UTC | newest] Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2004-05-28 7:09 [PATCH/RFA] PR target/13250 Kaz Kojima 2004-05-28 10:12 ` Alexandre Oliva 2004-05-28 11:01 ` Kaz Kojima 2004-05-28 14:23 ` Gabriel Dos Reis 2004-05-28 15:05 ` Joern Rennecke 2004-05-28 15:45 ` Kaz Kojima 2004-05-28 20:18 ` Joern Rennecke 2004-05-29 16:53 ` Kaz Kojima 2004-06-01 12:19 ` Joern Rennecke 2004-06-01 12:46 ` Kaz Kojima 2004-06-02 16:42 ` Joern Rennecke 2004-06-03 4:02 ` Kaz Kojima 2004-06-04 14:45 ` building sh-elf / sh-linux (Was: Re: [PATCH/RFA] PR target/13250) Joern Rennecke 2004-06-07 20:48 ` Joern Rennecke [not found] <no.id> 2004-06-04 15:56 ` Joern Rennecke 2004-06-04 18:25 ` Joern Rennecke
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).