This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/50168] __builtin_ctz() and intrinsics __bsr(), __bsf() generate suboptimal code on x86_64
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 24 Aug 2011 09:48:20 +0000
- Subject: [Bug middle-end/50168] __builtin_ctz() and intrinsics __bsr(), __bsf() generate suboptimal code on x86_64
- Auto-submitted: auto-generated
- References: <bug-50168-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50168
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-08-24 09:48:20 UTC ---
(In reply to comment #7)
> Hm, so the best thing we can do is a peephole recognizing that
>
> 10: 48 0f bc ff bsf %rdi,%rdi
> 14: 48 63 ff movslq %edi,%rdi
>
> when rdi is zero it will stay so and the movslq is redundant?
I don't think so. While the SandyBridge CPU seems to behave that way, there is
no such guarantee in the Intel manuals which say that the destination value is
undefined if zero-flag is cleared (i.e. the source was zero) and thus some
older or future CPUs might behave differently.