diff options
author | Craig Topper <craig.topper@gmail.com> | 2017-05-03 23:12:29 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2017-05-03 23:12:29 +0000 |
commit | 8189a87a1ed98a4f3fc3966e52ebad984f18f262 (patch) | |
tree | 3efca7e7607b0f58d48f1d185d0127bb1774477d /llvm/lib/Transforms/InstCombine | |
parent | b201a20eabd5292b2b4a2b0948eb26330d5da65b (diff) | |
download | bcm5719-llvm-8189a87a1ed98a4f3fc3966e52ebad984f18f262.tar.gz bcm5719-llvm-8189a87a1ed98a4f3fc3966e52ebad984f18f262.zip |
[KnownBits] Add methods for determining if KnownBits is a constant value
This patch adds isConstant and getConstant for determining if KnownBits represents a constant value and to retrieve the value. Use them to simplify code.
Differential Revision: https://reviews.llvm.org/D32785
llvm-svn: 302091
Diffstat (limited to 'llvm/lib/Transforms/InstCombine')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp index 1eb98b18bfb..1792cb585f8 100644 --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -2182,8 +2182,8 @@ Instruction *InstCombiner::visitReturnInst(ReturnInst &RI) { // determine the value. If so, constant fold it. KnownBits Known(VTy->getPrimitiveSizeInBits()); computeKnownBits(ResultOp, Known, 0, &RI); - if ((Known.Zero|Known.One).isAllOnesValue()) - RI.setOperand(0, Constant::getIntegerValue(VTy, Known.One)); + if (Known.isConstant()) + RI.setOperand(0, Constant::getIntegerValue(VTy, Known.getConstant())); return nullptr; } @@ -2863,8 +2863,8 @@ bool InstCombiner::run() { unsigned BitWidth = Ty->getScalarSizeInBits(); KnownBits Known(BitWidth); computeKnownBits(I, Known, /*Depth*/0, I); - if ((Known.Zero | Known.One).isAllOnesValue()) { - Constant *C = ConstantInt::get(Ty, Known.One); + if (Known.isConstant()) { + Constant *C = ConstantInt::get(Ty, Known.getConstant()); DEBUG(dbgs() << "IC: ConstFold (all bits known) to: " << *C << " from: " << *I << '\n'); |