public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "oneill+gccbugs at cs dot hmc.edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/62263] Good codegen for bitwise rotate requires code that is technically undefined behavior
Date: Tue, 26 Aug 2014 17:12:00 -0000 [thread overview]
Message-ID: <bug-62263-4-uKdA2xfJ62@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-62263-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62263
--- Comment #6 from M.E. O'Neill <oneill+gccbugs at cs dot hmc.edu> ---
(In reply to Marek Polacek from comment #3)
> We handle at least
> (x << n) | (x >> ((-n) & 31))
> (N can be 0 here) since PR57157.
Although this code does work with LLVM, testing with GCC 4.9.0, and this
implementation
unsigned int rotl32_doubleand4(unsigned int v, unsigned char r)
{
return (v << (r & 31)) | (v >> ((-r) & 31));
}
(or variations with r being a char or int) produces code like this:
_rotl32_doubleand4:
LFB6:
movl %esi, %ecx
movl %edi, %eax
negl %ecx
shrl %cl, %eax
movl %esi, %ecx
sall %cl, %edi
orl %edi, %eax
ret
... so it failed to spot the idiom entirely.
prev parent reply other threads:[~2014-08-26 17:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-26 0:45 [Bug middle-end/62263] New: " oneill+gccbugs at cs dot hmc.edu
2014-08-26 0:50 ` [Bug middle-end/62263] " oneill+gccbugs at cs dot hmc.edu
2014-08-26 11:18 ` rguenth at gcc dot gnu.org
2014-08-26 11:38 ` mpolacek at gcc dot gnu.org
2014-08-26 12:15 ` glisse at gcc dot gnu.org
2014-08-26 12:31 ` glisse at gcc dot gnu.org
2014-08-26 17:12 ` oneill+gccbugs at cs dot hmc.edu [this message]
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-62263-4-uKdA2xfJ62@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: link
Be 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).