public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "torvalds@linux-foundation.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/49095] Horrible code generation for trivial decrement with test Date: Sat, 21 May 2011 21:33:00 -0000 [thread overview] Message-ID: <bug-49095-4-t0xYQnScYk@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-49095-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49095 --- Comment #3 from Linus Torvalds <torvalds@linux-foundation.org> 2011-05-21 20:42:26 UTC --- Hmm. Looking at that code generation, it strikes me that even with the odd load store situation, why do we have that "test" instruction? c: 8b 10 mov (%eax),%edx e: 83 ea 01 sub $0x1,%edx 11: 85 d2 test %edx,%edx 13: 89 10 mov %edx,(%eax) 15: 74 09 je 20 <main+0x20> iow, regardless of any complexities of the store, that "sub + test" is just odd. Gcc knows to simplify that particular sequence in other situations, why doesn't it simplify it here? IOW, I can make gcc generate code like c: 83 e8 01 sub $0x1,%eax f: 75 07 jne 18 <main+0x18> with no real problem when it's in registers. No "test" instruction after the sub. Why does that store matter so much? It looks like the combine is bring driven by the conditional branch, and then when the previous instruction from the conditional branch is that store, everything kind of goes to hell. Would it be possible to have a peephole for the "arithmetic/logical + compare-with-zero" case (causing us to just drop the compare), and then have a separate peephole optimization that triggers the "load + op + store with dead reg" and turns that into a "op to mem" case? The MD files do make me confused, so maybe there is some fundamental limitation to the peephole patterns that makes this impossible?
next prev parent reply other threads:[~2011-05-21 20:57 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-05-21 3:46 [Bug other/49095] New: " torvalds@linux-foundation.org 2011-05-21 10:12 ` [Bug rtl-optimization/49095] " rguenth at gcc dot gnu.org 2011-05-21 19:22 ` torvalds@linux-foundation.org 2011-05-21 21:33 ` torvalds@linux-foundation.org [this message] 2011-05-27 10:50 ` jakub at gcc dot gnu.org 2011-05-27 12:30 ` jakub at gcc dot gnu.org 2011-05-27 14:22 ` torvalds@linux-foundation.org 2011-05-27 14:55 ` jakub at gcc dot gnu.org 2011-05-27 16:02 ` torvalds@linux-foundation.org 2011-05-27 16:36 ` jakub at gcc dot gnu.org 2011-05-27 16:52 ` torvalds@linux-foundation.org 2011-05-29 18:53 ` jakub at gcc dot gnu.org 2011-05-29 18:57 ` jakub at gcc dot gnu.org 2011-05-29 19:09 ` torvalds@linux-foundation.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-49095-4-t0xYQnScYk@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).