[Mlir-commits] [mlir] a9ef5bc - [MLIR] Avoid copies in xor range inference (NFC) (#221083)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Sep 3 15:52:37 PDT 2026
Author: Mehdi Amini
Date: 2026-09-03T22:52:32Z
New Revision: a9ef5bce7ab674b8294a9379a5fa6e3a157f4594
URL: https://github.com/llvm/llvm-project/commit/a9ef5bce7ab674b8294a9379a5fa6e3a157f4594
DIFF: https://github.com/llvm/llvm-project/commit/a9ef5bce7ab674b8294a9379a5fa6e3a157f4594.diff
LOG: [MLIR] Avoid copies in xor range inference (NFC) (#221083)
Borrow the input ranges and move local APInt values into bitwise
operations at their last use while computing varying-bit masks and
inferred xor bounds.
Found by Coverity.
Assisted-by: Codex
Added:
Modified:
mlir/lib/Interfaces/Utils/InferIntRangeCommon.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Interfaces/Utils/InferIntRangeCommon.cpp b/mlir/lib/Interfaces/Utils/InferIntRangeCommon.cpp
index ae97b1f50def6..2c91c82da5b21 100644
--- a/mlir/lib/Interfaces/Utils/InferIntRangeCommon.cpp
+++ b/mlir/lib/Interfaces/Utils/InferIntRangeCommon.cpp
@@ -572,7 +572,8 @@ mlir::intrange::inferOr(ArrayRef<ConstantIntRanges> argRanges) {
static APInt getVaryingBitsMask(const ConstantIntRanges &bound) {
APInt leftVal = bound.umin(), rightVal = bound.umax();
unsigned bitwidth = leftVal.getBitWidth();
- unsigned
diff eringBits = bitwidth - (leftVal ^ rightVal).countl_zero();
+ unsigned
diff eringBits =
+ bitwidth - (std::move(leftVal) ^ rightVal).countl_zero();
return APInt::getLowBitsSet(bitwidth,
diff eringBits);
}
@@ -580,11 +581,11 @@ ConstantIntRanges
mlir::intrange::inferXor(ArrayRef<ConstantIntRanges> argRanges) {
// Construct mask of varying bits for both ranges, xor values and then replace
// masked bits with 0s and 1s to get min and max values respectively.
- ConstantIntRanges lhs = argRanges[0], rhs = argRanges[1];
+ const ConstantIntRanges &lhs = argRanges[0], &rhs = argRanges[1];
APInt mask = getVaryingBitsMask(lhs) | getVaryingBitsMask(rhs);
APInt res = lhs.umin() ^ rhs.umin();
APInt min = res & ~mask;
- APInt max = res | mask;
+ APInt max = std::move(res) | mask;
return ConstantIntRanges::fromUnsigned(min, max);
}
More information about the Mlir-commits
mailing list