[PATCH] D109620: [APInt] Add a concat method, use LLVM_UNLIKELY to help optimizer.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 10 13:45:25 PDT 2021
craig.topper added inline comments.
================
Comment at: llvm/include/llvm/ADT/APInt.h:351
if (isSingleWord()) {
- if (BitWidth == 0)
+ if (LLVM_UNLIKELY(BitWidth == 0))
return false;
----------------
This is may be too subtle, but we can avoid a branch here if we use.
U.VAL == WORDTYPE_MAX >> ((APINT_BITS_PER_WORD - BitWidth) & 0x3f);
That will alias 64 and 0 to both use WORD_TYPE for the compare. Since U.VAL should always be 0 for BitWidth == 0. The compare would always fail.
================
Comment at: llvm/lib/Support/APInt.cpp:344
+ unsigned NewWidth = getBitWidth() + NewLSB.getBitWidth();
+ return (zext(NewWidth) << NewLSB.getBitWidth()) | NewLSB.zext(NewWidth);
+}
----------------
I was wondering if insertBits would be better here, but the last resort code in that resorts to copying bit by bit. But it would avoid a second heap allocation for widening the LSB. So maybe worth improving insertBits.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109620/new/
https://reviews.llvm.org/D109620
More information about the llvm-commits
mailing list