[PATCH] D117912: [IR] document and update ctlz/cttz intrinsics to optionally return poison rather than undef
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 21 14:05:42 PST 2022
spatel added a comment.
In D117912#3262368 <https://reviews.llvm.org/D117912#3262368>, @craig.topper wrote:
> In D117912#3262280 <https://reviews.llvm.org/D117912#3262280>, @spatel wrote:
>
>> In D117912#3262125 <https://reviews.llvm.org/D117912#3262125>, @efriedma wrote:
>>
>>> You mean, we might reach a point where we could make clang emit is_zero_poison=false without anyone caring? Don't think we're quite there yet. x86-64-v2 doesn't include lzcnt. And not sure about the current state of the compiler-rt/libgcc intrinsics.
>>
>> Yes, I was wondering what level of default x86 tuning was needed to flip the setting...I suppose that's x86-64-v3 ("Close to Haswell").
>
> Is updating isCheapToSpeculateCTTZ/CTLZ to check CMOV instead of BMI/LZCNT enough?
That would let this:
int clipped2(std::uint64_t a) { return (a == 0) ? 64 : __builtin_ctzll(a); }
Become:
bsfq %rdi, %rcx
movl $64, %eax
cmovneq %rcx, %rax
Instead of a 'test + je' around the bsf, so that's probably good. But I can't remember all of the corner-case patterns that we're trying to account for with these builtins.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D117912/new/
https://reviews.llvm.org/D117912
More information about the llvm-commits
mailing list