On x86-64 with clang 3.8, before:
mov edx, 1 mov cl, dil shl rdx, cl cmp rdi, 64 mov rax, -1 cmovne rax, rdx ret
after:
mov ecx, 64 sub ecx, edi mov rax, -1 shr rax, cl ret
Differential D22440
Use a faster implementation of maxUIntN. jlebar on Jul 16 2016, 3:17 PM. Authored by
Details On x86-64 with clang 3.8, before: mov edx, 1 mov cl, dil shl rdx, cl cmp rdi, 64 mov rax, -1 cmovne rax, rdx ret after: mov ecx, 64 sub ecx, edi mov rax, -1 shr rax, cl ret
Diff Detail
Event TimelineComment Actions LGTM with nits.
Comment Actions Use UINT64_MAX.
Comment Actions FYI: this made UBSan bot unhappy: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/14727/steps/check-llvm%20ubsan/logs/stdio [ RUN ] MathExtras.minIntN /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/Support/MathExtras.h:340:10: runtime error: negation of -9223372036854775808 cannot be represented in type 'long'; cast to an unsigned type to negate this value to itself #0 0x4fb9e3 in llvm::minIntN(long) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/Support/MathExtras.h:340:10 Comment Actions
FYI I think it was probably the patch I checked in to add tests for minIntN, D22443. Hooray for tests. |