[llvm] 1bd2cc5 - [InstCombine] Use KnownBits::udiv() helper
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed May 17 08:03:42 PDT 2023
Author: Nikita Popov
Date: 2023-05-17T17:03:35+02:00
New Revision: 1bd2cc5f7b50e31746a21c678daa765c0f9b4c4d
URL: https://github.com/llvm/llvm-project/commit/1bd2cc5f7b50e31746a21c678daa765c0f9b4c4d
DIFF: https://github.com/llvm/llvm-project/commit/1bd2cc5f7b50e31746a21c678daa765c0f9b4c4d.diff
LOG: [InstCombine] Use KnownBits::udiv() helper
This produces more precise results than the ad-hoc implementation.
Noticed while trying to add a consistency assertion.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index c9c7f4a53cc8..0d0522a18349 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -808,9 +808,8 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
return I;
}
- // Increase high zero bits from the input.
- Known.Zero.setHighBits(
- std::min(BitWidth, LHSKnown.Zero.countl_one() + RHSTrailingZeros));
+ Known = KnownBits::udiv(LHSKnown, KnownBits::makeConstant(*SA),
+ cast<BinaryOperator>(I)->isExact());
} else {
computeKnownBits(I, Known, Depth, CxtI);
}
More information about the llvm-commits
mailing list