[llvm-commits] PATCH: Initial patches for changing the semantics of llvm.cttz and llvm.ctlz
Chris Lattner
clattner at apple.com
Tue Dec 6 00:20:14 PST 2011
On Dec 5, 2011, at 3:37 AM, Stephen Canon wrote:
> On Dec 1, 2011, at 2:20 PM, Dan Gohman wrote:
>
>> The "old" semantics really are more desirable though, in general. The only
>> reason I know of for the "new" semantics is to cater to x86's old bsf and
>> bsr instructions. But x86 admits its own deficiency, and has since introduced
>> the lzcnt and tzcnt instructions, which behave properly. It seems unfortunate
>> to require people who want the sane semantics to use a branch (even if
>> CodeGen is clever and can eliminate it).
>
> Agreed. The x86 ISA semantics of BSR/BSF are nuts (and not followed by any other mainstream architecture with which I am familiar). Surely there's some way to give llvm the hint it needs to optimize this particular case on x86 without making the semantics of llvm ir similarly broken.
We have a winner here :). How about you change the intrinsics to "llvm.cttz(i32 X, i1 UndefOnZero)". That allows clean autoupgrade as well as capturing the extra information.
Also, if there is a intrinsics for the lzcnt instruction, please replace it with the newly enhanced llvm.ctlz intrinsic.
-Chris
More information about the llvm-commits
mailing list