summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2017-04-27 04:51:25 +0000
committerCraig Topper <craig.topper@gmail.com>2017-04-27 04:51:25 +0000
commit9474e9b6c8c5c1590070018593c868990c81d76a (patch)
treef7c3718452484be693306375899abb2b15d8a2bc /llvm/lib/Transforms
parent42fca6e7948117d7eb49a7ff2a51169b63e29e0e (diff)
downloadbcm5719-llvm-9474e9b6c8c5c1590070018593c868990c81d76a.tar.gz
bcm5719-llvm-9474e9b6c8c5c1590070018593c868990c81d76a.zip
[InstCombine] Use APInt bit counting methods to avoid a temporary APInt. NFC
llvm-svn: 301516
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 7985ec17ec9..597f1d95806 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1384,17 +1384,17 @@ static Instruction *foldCttzCtlz(IntrinsicInst &II, InstCombiner &IC) {
// Create a mask for bits above (ctlz) or below (cttz) the first known one.
bool IsTZ = II.getIntrinsicID() == Intrinsic::cttz;
- unsigned NumMaskBits = IsTZ ? Known.One.countTrailingZeros()
- : Known.One.countLeadingZeros();
- APInt Mask = IsTZ ? APInt::getLowBitsSet(BitWidth, NumMaskBits)
- : APInt::getHighBitsSet(BitWidth, NumMaskBits);
+ unsigned PossibleZeros = IsTZ ? Known.One.countTrailingZeros()
+ : Known.One.countLeadingZeros();
+ unsigned DefiniteZeros = IsTZ ? Known.Zero.countTrailingOnes()
+ : Known.Zero.countLeadingOnes();
// If all bits above (ctlz) or below (cttz) the first known one are known
// zero, this value is constant.
// FIXME: This should be in InstSimplify because we're replacing an
// instruction with a constant.
- if (Mask.isSubsetOf(Known.Zero)) {
- auto *C = ConstantInt::get(IT, APInt(BitWidth, NumMaskBits));
+ if (PossibleZeros == DefiniteZeros) {
+ auto *C = ConstantInt::get(IT, DefiniteZeros);
return IC.replaceInstUsesWith(II, C);
}
OpenPOWER on IntegriCloud