[llvm] 476ff03 - [InstSimplify] Cleanup out-of-range shift amount handling.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 22 09:02:49 PST 2021
Author: Simon Pilgrim
Date: 2021-02-22T17:00:49Z
New Revision: 476ff0327b7a97af50a15c7a8c3e0a6513627a8e
URL: https://github.com/llvm/llvm-project/commit/476ff0327b7a97af50a15c7a8c3e0a6513627a8e
DIFF: https://github.com/llvm/llvm-project/commit/476ff0327b7a97af50a15c7a8c3e0a6513627a8e.diff
LOG: [InstSimplify] Cleanup out-of-range shift amount handling.
Use APInt::uge() direct instead of getLimitedValue().
Use KnownBits::getMinValue() to make the bounds check more obvious.
Added:
Modified:
llvm/lib/Analysis/InstructionSimplify.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 1faf0092e874..4c8340c98fa0 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -1209,8 +1209,7 @@ static bool isPoisonShift(Value *Amount, const SimplifyQuery &Q) {
// Shifting by the bitwidth or more is undefined.
if (ConstantInt *CI = dyn_cast<ConstantInt>(C))
- if (CI->getValue().getLimitedValue() >=
- CI->getType()->getScalarSizeInBits())
+ if (CI->getValue().uge(CI->getType()->getScalarSizeInBits()))
return true;
// If all lanes of a vector shift are undefined the whole shift is.
@@ -1264,7 +1263,7 @@ static Value *SimplifyShift(Instruction::BinaryOps Opcode, Value *Op0,
// If any bits in the shift amount make that value greater than or equal to
// the number of bits in the type, the shift is undefined.
KnownBits Known = computeKnownBits(Op1, Q.DL, 0, Q.AC, Q.CxtI, Q.DT);
- if (Known.One.getLimitedValue() >= Known.getBitWidth())
+ if (Known.getMinValue().uge(Known.getBitWidth()))
return PoisonValue::get(Op0->getType());
// If all valid bits in the shift amount are known zero, the first operand is
More information about the llvm-commits
mailing list