public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "olly at survex dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/55299] New: missed optimization: ASR idiom Date: Mon, 12 Nov 2012 23:22:00 -0000 [thread overview] Message-ID: <bug-55299-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55299 Bug #: 55299 Summary: missed optimization: ASR idiom Classification: Unclassified Product: gcc Version: 4.7.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned@gcc.gnu.org ReportedBy: olly@survex.com This is similar to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54579 but for a different (and perhaps clearer) idiom for arithmetic shift right. I've filed this as a separate PR rather than adding it as a comment, but if it's actually the same issue underneath, please merge or mark as a duplicate. int asr(int a, int b) { return a < 0 ? ~((~a) >> b) : a >> b; } olly@gcc12:~$ /opt/cfarm/gcc-latest/bin/gcc -v Using built-in specs. COLLECT_GCC=/opt/cfarm/gcc-latest/bin/gcc COLLECT_LTO_WRAPPER=/home/iulius/autobuild/bin/gcc-4.7.1/libexec/gcc/x86_64-unknown-linux-gnu/4.7.1/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc-4.7.1-src/configure --prefix=/home/iulius/autobuild/bin/gcc-4.7.1 --with-gmp=/home/iulius/autobuild/bin/gmp-5.0.5 --with-mpfr=/home/iulius/autobuild/bin/mpfr-3.1.0 --with-mpc=/home/iulius/autobuild/bin/mpc-0.9 --disable-nls --enable-threads=posix --disable-multilib --enable-languages=c,c++ Thread model: posix gcc version 4.7.1 (GCC) Compiling with: LD_LIBRARY_PATH=/opt/cfarm/mpc-latest/lib:/opt/cfarm/mpfr-latest/lib:/opt/cfarm/gmp-latest/lib /opt/cfarm/gcc-latest/bin/gcc -O2 -S asr.c -o asr.S Gives this for the function asr: asr: .LFB0: movl %edi, %eax movl %esi, %ecx sarl %cl, %eax testl %edi, %edi js .L5 rep ret .p2align 4,,10 .p2align 3 .L5: movl %edi, %eax notl %eax sarl %cl, %eax notl %eax ret Ideally the conditional would be optimised down to just the sarl instruction. I've checked the older compiler versions on gcc12 (back to 4.1.1) and they all leave the branch in. So if this is a regression, it isn't at all recent.
next reply other threads:[~2012-11-12 23:22 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-11-12 23:22 olly at survex dot com [this message] 2012-11-13 14:58 ` [Bug c/55299] " hjl.tools at gmail dot com 2012-11-13 20:40 ` olly at survex dot com
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-55299-4@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).