Following compare-debug failure breaks bootstrap on alpha-linux-gnu on 4.6: --cut here-- void foo (char *c) { unsigned int x = 0; unsigned int i; for (i = 0; c[i]; i++) { if (i >= 5 && x != 1) break; else if (c[i] == ' ') x = i; else if (c[i] == '/' && c[i + 1] != ' ' && i) x = i + 1; } } --cut here-- The compare-debug failure can be reproduced on a cross to alpha-linux-gnu: ~/gcc-build-alpha/gcc/xgcc -B ~/gcc-build-alpha/gcc -O2 -fcompare-debug -S t.c xgcc: error: t.c: -fcompare-debug failure ~/gcc-build-alpha/gcc/xgcc -v Using built-in specs. COLLECT_GCC=/home/uros/gcc-build-alpha/gcc/xgcc Target: alpha-linux-gnu Configured with: ../gcc-svn/branches/gcc-4_6-branch/configure --target=alpha-linux-gnu Thread model: posix gcc version 4.6.4 20130117 (prerelease) [gcc-4_6-branch revision 195276] (GCC) The resulting assembly differs in: --with g-- $L8: $LM8: cmpeq $5,1,$5 # 30 *setcc_internal [length = 4] cmpult $8,$2,$2 # 35 *setcc_internal [length = 4] cmpeq $5,0,$5 # 31 *setcc_internal [length = 4] (*) addl $3,1,$3 # 43 *addsi_se/1 [length = 4] and $5,$2,$2 # 39 anddi3/1 [length = 4] cpys $f31,$f31,$f31 # 171 fnop [length = 4] (**) addl $4,1,$4 # 41 *addsi_se/1 [length = 4] bne $2,$L1 # 44 *bcc_normal [length = 4] $L9: --/with g-- --without g-- $L8: cmpeq $5,1,$5 # 26 *setcc_internal [length = 4] cmpult $8,$2,$2 # 31 *setcc_internal [length = 4] cmpeq $5,0,$5 # 27 *setcc_internal [length = 4] (**) addl $4,1,$4 # 37 *addsi_se/1 [length = 4] and $5,$2,$2 # 35 anddi3/1 [length = 4] cpys $f31,$f31,$f31 # 143 fnop [length = 4] (*) addl $3,1,$3 # 39 *addsi_se/1 [length = 4] bne $2,$L1 # 40 *bcc_normal [length = 4] $L9: --/without g-- Insns (*) and (**) switched places when compiled w/ or w/o "-g". The problem is in sched1 pass, where the first difference occurs, and adding -fno-schedule-insns to compile flags avoids the failure.
Created attachment 29197 [details] Preprocessed source of the file that miscompares during bootstrap This is the preprocessed source of the file that miscompares during bootstrap. ~/gcc-build-alpha/gcc/xgcc -B ~/gcc-build-alpha/gcc -O2 -fcompare-debug -S opts.i xgcc: error: opts.i: -fcompare-debug failure
Confirm bug and add CC.
Can you fill out known-to-work? Especially whether 4.7.x works and whether 4.6.3 worked?
4.7.3 [1] bootstraps OK, also passes -fcompare-debug test. [1] gcc version 4.7.3 20130118 (prerelease) [gcc-4_7-branch revision 195292]
Bookkeeping seems somehow broken to me in sched1 pass: -O2 -fcompare-debug -fdump-rtl-sched1-slim -S: _.c.190r.sched1: ;; ====================================================== ;; -- basic block 5 from 48 to 49 -- before reload ;; ====================================================== changing bb of uid 64 from 8 to 5 ;; 0--> 64 r137=zxn(r76#0) ;; 1--> 48 r111=r90==0x20 changing bb of uid 65 from 8 to 5 ;; 2--> 65 r119=r95+r137 ;; 2--> 49 pc={(r111==0)?L59:pc} ;; Ready list (final): ;; total time = 2 ;; new head = 48 ;; new tail = 49 New head is 64, *not* 48. And here comes the difference: _.c.190r.sched1: ;; ====================================================== ;; -- basic block 10 from 94 to 94 -- before reload ;; ====================================================== changing bb of uid 25 from 4 to 10 ;; 1--> 25 r100=zxn(r75#0) ;; 1--> 94 pc={(r90!=0)?L93:pc} ;; Ready list (final): 39/b6:18 37/b6:17 ;; total time = 1 ;; new head = 94 ;; new tail = 94 Again wrong head w/o -g. _.c.gk.190r.sched1 ;; ====================================================== ;; -- basic block 10 from 99 to 102 -- before reload ;; ====================================================== ;; 0--> 99: debug i => r76#0 ;; 0--> 100: debug x => r75#0 changing bb of uid 29 from 4 to 10 ;; 1--> 29 r100=zxn(r75#0) ;; 1--> 102 pc={(r90!=0)?L101:pc} ;; Ready list (final): 43/b6:20 41/b6:19 ;; total time = 1 ;; new head = 99 ;; new tail = 102 Here we account debug instructions as head. I suspect that this is the cause of the difference in a follow-up block, where we schedule in a different ways: _.c.190r.sched1: ;; ====================================================== ;; -- basic block 4 from 26 to 40 -- before reload ;; ====================================================== ;; 1--> 26 r102=r100==0x1 ;; 2--> 31 r105=ltu(r138,r137) ;; 3--> 27 r101=r102==0 ;; 4--> 37 r92=sxn(r92#0+0x1) ;; 5--> 35 r79=r101&r105 ;; 6--> 39 r76=sxn(r76#0+0x1) ;; 6--> 40 pc={(r79!=0)?L97:pc} _.c.gk.190r.sched1 ;; ====================================================== ;; -- basic block 4 from 30 to 44 -- before reload ;; ====================================================== ;; 0--> 43 r76=sxn(r76#0+0x1) ;; 1--> 30 r102=r100==0x1 ;; 2--> 35 r105=ltu(r138,r137) ;; 3--> 31 r101=r102==0 ;; 4--> 41 r92=sxn(r92#0+0x1) ;; 5--> 39 r79=r101&r105 ;; 6--> 44 pc={(r79!=0)?L105:pc} In the later dump, (insn 43) was scheduled above all others.
(In reply to comment #5) > Bookkeeping seems somehow broken to me in sched1 pass: *IF* this is problematic, then 4.7+ releases have the same problem.
Similar to (or the same as) PR 48403.
The scheduler passes block boundary here and schedules insns from the next block. This is the difference to the compilation w/o -g and to gcc-4_7 branch. ;; ====================================================== ;; -- basic block 10 from 99 to 102 -- before reload ;; ====================================================== ;; --------------- forward dependences: ------------ ;; --- Region Dependences --- b 10 bb 5 ;; insn code bb dep prio cost reservation ;; ---- ---- -- --- ---- ---- ----------- ;; 99 -1 10 0 0 0 nothing : 43 100 ;; 100 -1 10 1 0 0 nothing : ;; 102 184 10 0 2 2 (ev4_ib1+ev4_bbox),ev4_bbox : 44 ;; --- Region Dependences --- b 4 bb 6 ;; insn code bb dep prio cost reservation ;; ---- ---- -- --- ---- ---- ----------- ;; 29 52 4 0 9 2 (ev4_ib0+ev4_ebox) : 44 30 ;; 30 159 4 1 7 2 (ev4_ib0+ev4_ebox) : 44 31 ;; 31 159 4 1 5 2 (ev4_ib0+ev4_ebox) : 44 39 ;; 35 159 4 0 5 2 (ev4_ib0+ev4_ebox) : 44 39 ;; 37 NOTE_INSN_DELETED ;; 38 NOTE_INSN_DELETED ;; 39 41 4 2 3 2 (ev4_ib0+ev4_ebox) : 44 ;; 40 NOTE_INSN_DELETED ;; 41 3 4 0 2 2 (ev4_ib0+ev4_ebox) : 44 ;; 42 NOTE_INSN_DELETED ;; 43 3 4 0 2 2 (ev4_ib0+ev4_ebox) : 44 ;; 44 184 4 8 2 2 (ev4_ib1+ev4_bbox),ev4_bbox : ;; dependencies resolved: insn 99 ;; tick updated: insn 99 into ready ;; dependencies resolved: insn 102 ;; Ready-->Q: insn 102: queued for 2 cycles. ;; tick updated: insn 102 into queue with cost=2 ;; dependencies resolved: insn 29/b6 ;; Ready-->Q: insn 29/b6: queued for 2 cycles. ;; tick updated: insn 29/b6 into queue with cost=2 ;; dependencies resolved: insn 35/b6 ;; Ready-->Q: insn 35/b6: queued for 2 cycles. ;; tick updated: insn 35/b6 into queue with cost=2 ;; dependencies resolved: insn 41/b6 ;; Ready-->Q: insn 41/b6: queued for 2 cycles. ;; tick updated: insn 41/b6 into queue with cost=2 ;; dependencies resolved: insn 43/b6 ;; Ready-->Q: insn 43/b6: queued for 2 cycles. ;; tick updated: insn 43/b6 into queue with cost=2 ;; Advanced a state. ;; ...
Following patch fixes bootstrap comparison failure: --cut here-- Index: haifa-sched.c =================================================================== --- haifa-sched.c (revision 195276) +++ haifa-sched.c (working copy) @@ -3684,6 +3684,9 @@ fix_inter_tick (rtx head, rtx tail) INSN_TICK (head) = tick; } + if (DEBUG_INSN_P (head)) + continue; + FOR_EACH_DEP (head, SD_LIST_RES_FORW, sd_it, dep) { rtx next; --cut here-- We should not update tick status of instructions, dependent on debug insn.
Patch at [1]. [1] http://gcc.gnu.org/ml/gcc-patches/2013-01/msg01011.html
Author: uros Date: Mon Jan 21 17:51:23 2013 New Revision: 195342 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195342 Log: PR rtl-optimization/56023 * haifa-sched.c (fix_inter_tick): Do not update ticks of instructions, dependent on debug instruction. testsuite/ChangeLog: PR rtl-optimization/56023 * gcc.dg/pr56023.c: New test. Added: trunk/gcc/testsuite/gcc.dg/pr56023.c Modified: trunk/gcc/ChangeLog trunk/gcc/haifa-sched.c trunk/gcc/testsuite/ChangeLog
Author: uros Date: Mon Jan 21 17:59:28 2013 New Revision: 195344 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195344 Log: PR rtl-optimization/56023 * haifa-sched.c (fix_inter_tick): Do not update ticks of instructions, dependent on debug instruction. testsuite/ChangeLog: PR rtl-optimization/56023 * gcc.dg/pr56023.c: New test. Added: branches/gcc-4_7-branch/gcc/testsuite/gcc.dg/pr56023.c Modified: branches/gcc-4_7-branch/gcc/ChangeLog branches/gcc-4_7-branch/gcc/haifa-sched.c branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
Author: uros Date: Mon Jan 21 18:02:57 2013 New Revision: 195345 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195345 Log: PR rtl-optimization/56023 * haifa-sched.c (fix_inter_tick): Do not update ticks of instructions, dependent on debug instruction. testsuite/ChangeLog: PR rtl-optimization/56023 * gcc.dg/pr56023.c: New test. Added: branches/gcc-4_6-branch/gcc/testsuite/gcc.dg/pr56023.c Modified: branches/gcc-4_6-branch/gcc/ChangeLog branches/gcc-4_6-branch/gcc/haifa-sched.c branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
Fixed everywhere.