[llvm] 5620542 - [IR] Add `getNoWrapKind` method for `OverflowingBinaryOperator` (NFC)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 8 08:04:16 PST 2024
Author: Antonio Frighetto
Date: 2024-03-08T17:00:58+01:00
New Revision: 5620542e4d19f794a0d6bd1bd1861bcedd7a788a
URL: https://github.com/llvm/llvm-project/commit/5620542e4d19f794a0d6bd1bd1861bcedd7a788a
DIFF: https://github.com/llvm/llvm-project/commit/5620542e4d19f794a0d6bd1bd1861bcedd7a788a.diff
LOG: [IR] Add `getNoWrapKind` method for `OverflowingBinaryOperator` (NFC)
Added:
Modified:
llvm/include/llvm/IR/Operator.h
llvm/lib/Analysis/LazyValueInfo.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/Operator.h b/llvm/include/llvm/IR/Operator.h
index 7168128648d8e2..e5264983390109 100644
--- a/llvm/include/llvm/IR/Operator.h
+++ b/llvm/include/llvm/IR/Operator.h
@@ -109,6 +109,18 @@ class OverflowingBinaryOperator : public Operator {
return (SubclassOptionalData & NoSignedWrap) != 0;
}
+ /// Returns the no-wrap kind of the operation.
+ unsigned getNoWrapKind() const {
+ unsigned NoWrapKind = 0;
+ if (hasNoUnsignedWrap())
+ NoWrapKind |= NoUnsignedWrap;
+
+ if (hasNoSignedWrap())
+ NoWrapKind |= NoSignedWrap;
+
+ return NoWrapKind;
+ }
+
static bool classof(const Instruction *I) {
return I->getOpcode() == Instruction::Add ||
I->getOpcode() == Instruction::Sub ||
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp
index b948eb6ebd1266..9ae31d165235ca 100644
--- a/llvm/lib/Analysis/LazyValueInfo.cpp
+++ b/llvm/lib/Analysis/LazyValueInfo.cpp
@@ -997,12 +997,7 @@ LazyValueInfoImpl::solveBlockValueBinaryOp(BinaryOperator *BO, BasicBlock *BB) {
assert(BO->getOperand(0)->getType()->isSized() &&
"all operands to binary operators are sized");
if (auto *OBO = dyn_cast<OverflowingBinaryOperator>(BO)) {
- unsigned NoWrapKind = 0;
- if (OBO->hasNoUnsignedWrap())
- NoWrapKind |= OverflowingBinaryOperator::NoUnsignedWrap;
- if (OBO->hasNoSignedWrap())
- NoWrapKind |= OverflowingBinaryOperator::NoSignedWrap;
-
+ unsigned NoWrapKind = OBO->getNoWrapKind();
return solveBlockValueBinaryOpImpl(
BO, BB,
[BO, NoWrapKind](const ConstantRange &CR1, const ConstantRange &CR2) {
More information about the llvm-commits
mailing list