Skip to content

Commit 5620542

Browse files
[IR] Add getNoWrapKind method for OverflowingBinaryOperator (NFC)
1 parent b46f980 commit 5620542

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

llvm/include/llvm/IR/Operator.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,18 @@ class OverflowingBinaryOperator : public Operator {
109109
return (SubclassOptionalData & NoSignedWrap) != 0;
110110
}
111111

112+
/// Returns the no-wrap kind of the operation.
113+
unsigned getNoWrapKind() const {
114+
unsigned NoWrapKind = 0;
115+
if (hasNoUnsignedWrap())
116+
NoWrapKind |= NoUnsignedWrap;
117+
118+
if (hasNoSignedWrap())
119+
NoWrapKind |= NoSignedWrap;
120+
121+
return NoWrapKind;
122+
}
123+
112124
static bool classof(const Instruction *I) {
113125
return I->getOpcode() == Instruction::Add ||
114126
I->getOpcode() == Instruction::Sub ||

llvm/lib/Analysis/LazyValueInfo.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -997,12 +997,7 @@ LazyValueInfoImpl::solveBlockValueBinaryOp(BinaryOperator *BO, BasicBlock *BB) {
997997
assert(BO->getOperand(0)->getType()->isSized() &&
998998
"all operands to binary operators are sized");
999999
if (auto *OBO = dyn_cast<OverflowingBinaryOperator>(BO)) {
1000-
unsigned NoWrapKind = 0;
1001-
if (OBO->hasNoUnsignedWrap())
1002-
NoWrapKind |= OverflowingBinaryOperator::NoUnsignedWrap;
1003-
if (OBO->hasNoSignedWrap())
1004-
NoWrapKind |= OverflowingBinaryOperator::NoSignedWrap;
1005-
1000+
unsigned NoWrapKind = OBO->getNoWrapKind();
10061001
return solveBlockValueBinaryOpImpl(
10071002
BO, BB,
10081003
[BO, NoWrapKind](const ConstantRange &CR1, const ConstantRange &CR2) {

0 commit comments

Comments
 (0)