public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug target/40983] New: The scheduler incorrectly swaps MMX and floating point instructions @ 2009-08-06 4:11 mikulas at artax dot karlin dot mff dot cuni dot cz 2009-08-06 4:12 ` [Bug target/40983] " mikulas at artax dot karlin dot mff dot cuni dot cz ` (5 more replies) 0 siblings, 6 replies; 7+ messages in thread From: mikulas at artax dot karlin dot mff dot cuni dot cz @ 2009-08-06 4:11 UTC (permalink / raw) To: gcc-bugs Hi This example fails, because in function "f", the scheduler incorrectly swapped floating point store to "c" and load of mmx registers. Compile with -O2 -march=pentium-mmx -- Summary: The scheduler incorrectly swaps MMX and floating point instructions Product: gcc Version: 4.4.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: mikulas at artax dot karlin dot mff dot cuni dot cz GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40983 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/40983] The scheduler incorrectly swaps MMX and floating point instructions 2009-08-06 4:11 [Bug target/40983] New: The scheduler incorrectly swaps MMX and floating point instructions mikulas at artax dot karlin dot mff dot cuni dot cz @ 2009-08-06 4:12 ` mikulas at artax dot karlin dot mff dot cuni dot cz 2009-08-06 4:15 ` mikulas at artax dot karlin dot mff dot cuni dot cz ` (4 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: mikulas at artax dot karlin dot mff dot cuni dot cz @ 2009-08-06 4:12 UTC (permalink / raw) To: gcc-bugs ------- Comment #1 from mikulas at artax dot karlin dot mff dot cuni dot cz 2009-08-06 04:12 ------- Created an attachment (id=18310) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18310&action=view) A failing example -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40983 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/40983] The scheduler incorrectly swaps MMX and floating point instructions 2009-08-06 4:11 [Bug target/40983] New: The scheduler incorrectly swaps MMX and floating point instructions mikulas at artax dot karlin dot mff dot cuni dot cz 2009-08-06 4:12 ` [Bug target/40983] " mikulas at artax dot karlin dot mff dot cuni dot cz @ 2009-08-06 4:15 ` mikulas at artax dot karlin dot mff dot cuni dot cz 2009-08-06 10:47 ` ubizjak at gmail dot com ` (3 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: mikulas at artax dot karlin dot mff dot cuni dot cz @ 2009-08-06 4:15 UTC (permalink / raw) To: gcc-bugs ------- Comment #2 from mikulas at artax dot karlin dot mff dot cuni dot cz 2009-08-06 04:15 ------- Assembler output: f: pushl %ebp movl %esp, %ebp subl $16, %esp movq %mm0, -8(%ebp) movq %mm1, -16(%ebp) emms fldl a faddl b movq -8(%ebp), %mm0 paddd -16(%ebp), %mm0 fstpl c leave ret -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40983 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/40983] The scheduler incorrectly swaps MMX and floating point instructions 2009-08-06 4:11 [Bug target/40983] New: The scheduler incorrectly swaps MMX and floating point instructions mikulas at artax dot karlin dot mff dot cuni dot cz 2009-08-06 4:12 ` [Bug target/40983] " mikulas at artax dot karlin dot mff dot cuni dot cz 2009-08-06 4:15 ` mikulas at artax dot karlin dot mff dot cuni dot cz @ 2009-08-06 10:47 ` ubizjak at gmail dot com 2009-08-23 19:19 ` mikulas at artax dot karlin dot mff dot cuni dot cz ` (2 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: ubizjak at gmail dot com @ 2009-08-06 10:47 UTC (permalink / raw) To: gcc-bugs ------- Comment #3 from ubizjak at gmail dot com 2009-08-06 10:47 ------- Hm, we can fix this by teaching scheduler that every access to %mm registers clobbers FP state. Since scheduler already depend all x87 instructions on Top-Of-Stack (TOS) register, we can perhaps extend this requirement for all instructions that use %mm reg. Something like the proof-of-concept patch bellow: --cut here-- Index: sched-deps.c =================================================================== --- sched-deps.c (revision 150503) +++ sched-deps.c (working copy) @@ -1898,7 +1898,12 @@ sched_analyze_reg (deps, FIRST_STACK_REG, mode, code, insn); sched_analyze_reg (deps, FIRST_STACK_REG, mode, USE, insn); } + +#ifdef FIRST_MMX_REG + if (regno >= FIRST_MMX_REG && regno <= LAST_MMX_REG) + sched_analyze_reg (deps, FIRST_STACK_REG, VOIDmode, CLOBBER, insn); #endif +#endif } else if (MEM_P (dest)) { @@ -2044,7 +2049,12 @@ sched_analyze_reg (deps, FIRST_STACK_REG, mode, USE, insn); sched_analyze_reg (deps, FIRST_STACK_REG, mode, SET, insn); } + +#ifdef FIRST_MMX_REG + if (regno >= FIRST_MMX_REG && regno <= LAST_MMX_REG) + sched_analyze_reg (deps, FIRST_STACK_REG, VOIDmode, CLOBBER, insn); #endif +#endif if (cslr_p && sched_deps_info->finish_rhs) sched_deps_info->finish_rhs (); --cut here-- Otherwise, you can just add "asm volatile ("")" as a scheduling barrier. -- ubizjak at gmail dot com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Last reconfirmed|0000-00-00 00:00:00 |2009-08-06 10:47:08 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40983 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/40983] The scheduler incorrectly swaps MMX and floating point instructions 2009-08-06 4:11 [Bug target/40983] New: The scheduler incorrectly swaps MMX and floating point instructions mikulas at artax dot karlin dot mff dot cuni dot cz ` (2 preceding siblings ...) 2009-08-06 10:47 ` ubizjak at gmail dot com @ 2009-08-23 19:19 ` mikulas at artax dot karlin dot mff dot cuni dot cz 2009-10-16 19:46 ` sezeroz at gmail dot com 2009-11-11 23:06 ` mikulas at artax dot karlin dot mff dot cuni dot cz 5 siblings, 0 replies; 7+ messages in thread From: mikulas at artax dot karlin dot mff dot cuni dot cz @ 2009-08-23 19:19 UTC (permalink / raw) To: gcc-bugs ------- Comment #4 from mikulas at artax dot karlin dot mff dot cuni dot cz 2009-08-23 19:18 ------- The patch works fine. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40983 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/40983] The scheduler incorrectly swaps MMX and floating point instructions 2009-08-06 4:11 [Bug target/40983] New: The scheduler incorrectly swaps MMX and floating point instructions mikulas at artax dot karlin dot mff dot cuni dot cz ` (3 preceding siblings ...) 2009-08-23 19:19 ` mikulas at artax dot karlin dot mff dot cuni dot cz @ 2009-10-16 19:46 ` sezeroz at gmail dot com 2009-11-11 23:06 ` mikulas at artax dot karlin dot mff dot cuni dot cz 5 siblings, 0 replies; 7+ messages in thread From: sezeroz at gmail dot com @ 2009-10-16 19:46 UTC (permalink / raw) To: gcc-bugs ------- Comment #5 from sezeroz at gmail dot com 2009-10-16 19:45 ------- Any progress on this? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40983 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/40983] The scheduler incorrectly swaps MMX and floating point instructions 2009-08-06 4:11 [Bug target/40983] New: The scheduler incorrectly swaps MMX and floating point instructions mikulas at artax dot karlin dot mff dot cuni dot cz ` (4 preceding siblings ...) 2009-10-16 19:46 ` sezeroz at gmail dot com @ 2009-11-11 23:06 ` mikulas at artax dot karlin dot mff dot cuni dot cz 5 siblings, 0 replies; 7+ messages in thread From: mikulas at artax dot karlin dot mff dot cuni dot cz @ 2009-11-11 23:06 UTC (permalink / raw) To: gcc-bugs ------- Comment #6 from mikulas at artax dot karlin dot mff dot cuni dot cz 2009-11-11 23:06 ------- I think you can commit it to gcc. I don't see a reason why it shouldn't be committed. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40983 ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-11-11 23:06 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2009-08-06 4:11 [Bug target/40983] New: The scheduler incorrectly swaps MMX and floating point instructions mikulas at artax dot karlin dot mff dot cuni dot cz 2009-08-06 4:12 ` [Bug target/40983] " mikulas at artax dot karlin dot mff dot cuni dot cz 2009-08-06 4:15 ` mikulas at artax dot karlin dot mff dot cuni dot cz 2009-08-06 10:47 ` ubizjak at gmail dot com 2009-08-23 19:19 ` mikulas at artax dot karlin dot mff dot cuni dot cz 2009-10-16 19:46 ` sezeroz at gmail dot com 2009-11-11 23:06 ` mikulas at artax dot karlin dot mff dot cuni dot cz
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).