[llvm] be1ffda - [InstCombine] visitCallInst - pull out repeated bswap scalar type bitwidth. NFC.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 18 09:37:25 PST 2022
Author: Simon Pilgrim
Date: 2022-02-18T17:33:11Z
New Revision: be1ffda0a5b9a0fee866ec01cc3a7c3cb0cd712e
URL: https://github.com/llvm/llvm-project/commit/be1ffda0a5b9a0fee866ec01cc3a7c3cb0cd712e
DIFF: https://github.com/llvm/llvm-project/commit/be1ffda0a5b9a0fee866ec01cc3a7c3cb0cd712e.diff
LOG: [InstCombine] visitCallInst - pull out repeated bswap scalar type bitwidth. NFC.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index eecd583740c30..0abe34da2c262 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1295,9 +1295,10 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
KnownBits Known = computeKnownBits(IIOperand, 0, II);
uint64_t LZ = alignDown(Known.countMinLeadingZeros(), 8);
uint64_t TZ = alignDown(Known.countMinTrailingZeros(), 8);
+ unsigned BW = Known.getBitWidth();
// bswap(x) -> shift(x) if x has exactly one "active byte"
- if (Known.getBitWidth() - LZ - TZ == 8) {
+ if (BW - LZ - TZ == 8) {
assert(LZ != TZ && "active byte cannot be in the middle");
if (LZ > TZ) // -> shl(x) if the "active byte" is in the low part of x
return BinaryOperator::CreateNUWShl(
@@ -1309,8 +1310,7 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
// bswap(trunc(bswap(x))) -> trunc(lshr(x, c))
if (match(IIOperand, m_Trunc(m_BSwap(m_Value(X))))) {
- unsigned C = X->getType()->getScalarSizeInBits() -
- IIOperand->getType()->getScalarSizeInBits();
+ unsigned C = X->getType()->getScalarSizeInBits() - BW;
Value *CV = ConstantInt::get(X->getType(), C);
Value *V = Builder.CreateLShr(X, CV);
return new TruncInst(V, IIOperand->getType());
More information about the llvm-commits
mailing list