[llvm] [IR] Add `getNoWrapKind` method for `OverflowingBinaryOperator` (NFC) (PR #84502)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 8 07:36:54 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-ir
Author: Antonio Frighetto (antoniofrighetto)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/84502.diff
2 Files Affected:
- (modified) llvm/include/llvm/IR/Operator.h (+12)
- (modified) llvm/lib/Analysis/LazyValueInfo.cpp (+1-6)
``````````diff
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) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/84502
More information about the llvm-commits
mailing list