[Mlir-commits] [mlir] 6786d7e - Apply clang-tidy fixes for readability-simplify-boolean-expr to MLIR (NFC)
Mehdi Amini
llvmlistbot at llvm.org
Sat Jan 1 18:01:22 PST 2022
Author: Mehdi Amini
Date: 2022-01-02T01:59:31Z
New Revision: 6786d7e4f5b14c4913d17410042fa226fad7187b
URL: https://github.com/llvm/llvm-project/commit/6786d7e4f5b14c4913d17410042fa226fad7187b
DIFF: https://github.com/llvm/llvm-project/commit/6786d7e4f5b14c4913d17410042fa226fad7187b.diff
LOG: Apply clang-tidy fixes for readability-simplify-boolean-expr to MLIR (NFC)
Reviewed By: rriddle, Mogball
Differential Revision: https://reviews.llvm.org/D116253
Added:
Modified:
mlir/lib/Analysis/Utils.cpp
mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp
mlir/lib/Dialect/Linalg/ComprehensiveBufferize/ComprehensiveBufferize.cpp
mlir/lib/Dialect/Linalg/ComprehensiveBufferize/LinalgInterfaceImpl.cpp
mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp
mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
mlir/lib/Dialect/StandardOps/Transforms/FuncConversions.cpp
mlir/lib/Dialect/Vector/VectorUtils.cpp
mlir/lib/Transforms/NormalizeMemRefs.cpp
mlir/lib/Transforms/Utils/LoopFusionUtils.cpp
mlir/lib/Transforms/Utils/LoopUtils.cpp
mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp
mlir/test/lib/Dialect/Vector/TestVectorTransforms.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Analysis/Utils.cpp b/mlir/lib/Analysis/Utils.cpp
index 432aeecde2db6..de78f1dfdf48b 100644
--- a/mlir/lib/Analysis/Utils.cpp
+++ b/mlir/lib/Analysis/Utils.cpp
@@ -564,7 +564,7 @@ LogicalResult MemRefRegion::compute(Operation *op, unsigned loopDepth,
for (auto id : ids) {
AffineForOp iv;
if ((iv = getForInductionVarOwner(id)) &&
- llvm::is_contained(enclosingIVs, iv) == false) {
+ !llvm::is_contained(enclosingIVs, iv)) {
cst.projectOut(id);
}
}
diff --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
index 9ddad2af4dc6b..38c8276f28430 100644
--- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
+++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
@@ -1014,11 +1014,7 @@ static bool createReassociationMapsForCollapse(
// If both iterators didn't reach the end, we have leftover dimentions which
// implies that we have a mismatch in shape.
- if (currSrcDim != srcShape.size() || currDstDim != dstShape.size()) {
- return false;
- }
-
- return true;
+ return !(currSrcDim != srcShape.size() || currDstDim != dstShape.size());
}
namespace {
diff --git a/mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp b/mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp
index 985cfc9b91e24..30bad881a3194 100644
--- a/mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp
+++ b/mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp
@@ -84,9 +84,7 @@ static bool transferReadSupportsMMAMatrixType(vector::TransferReadOp readOp) {
readOp.getContext());
// TODO: Support transpose once it is added to GPU dialect ops.
// For now we only support (d0, d1) -> (d0, d1) and (d0, d1) -> (0, d1).
- if (!map.isMinorIdentity() && map != broadcastInnerDim)
- return false;
- return true;
+ return !(!map.isMinorIdentity() && map != broadcastInnerDim);
}
// Return true if the transfer op can be converted to a MMA matrix store.
diff --git a/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/ComprehensiveBufferize.cpp b/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/ComprehensiveBufferize.cpp
index babbec5493aea..485fb735b3ee4 100644
--- a/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/ComprehensiveBufferize.cpp
+++ b/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/ComprehensiveBufferize.cpp
@@ -472,10 +472,7 @@ wouldCreateWriteToNonWritableBuffer(OpOperand &opOperand, OpResult opResult,
bool hasWrite = aliasesInPlaceWrite(opResult, aliasInfo, state) ||
aliasesInPlaceWrite(opOperand.get(), aliasInfo, state) ||
state.bufferizesToMemoryWrite(opOperand);
- if (!hasWrite)
- return false;
-
- return true;
+ return hasWrite;
}
//===----------------------------------------------------------------------===//
diff --git a/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/LinalgInterfaceImpl.cpp b/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/LinalgInterfaceImpl.cpp
index 158ad6a76343e..190f0fea5108e 100644
--- a/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/LinalgInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/LinalgInterfaceImpl.cpp
@@ -425,12 +425,10 @@ LogicalResult mlir::linalg::comprehensive_bufferize::linalg_ext::
// TODO: Support cases such as extract_slice(init_tensor).
SmallVector<OpOperand *> opOperands =
state.getAliasingOpOperand(opResult);
- if (!llvm::all_of(opOperands, [&](OpOperand *operand) {
- return aliasInfo.areEquivalentBufferizedValues(operand->get(),
- opResult);
- }))
- return true;
- return false;
+ return !llvm::all_of(opOperands, [&](OpOperand *operand) {
+ return aliasInfo.areEquivalentBufferizedValues(operand->get(),
+ opResult);
+ });
});
// Replace only if the reverse use-def chain ends at exactly one
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp b/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp
index 8812dd4dff762..aa8a3b9f47715 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp
@@ -543,14 +543,11 @@ struct LinalgDetensorize : public LinalgDetensorizeBase<LinalgDetensorize> {
if (op->hasTrait<OpTrait::FunctionLike>()) {
auto &body = function_like_impl::getFunctionBody(op);
return llvm::all_of(llvm::drop_begin(body, 1), [&](Block &block) {
- if (llvm::any_of(
- blockArgsToDetensor, [&](BlockArgument blockArgument) {
- return blockArgument.getOwner() == &block &&
- !typeConverter.isLegal(blockArgument.getType());
- })) {
- return false;
- }
- return true;
+ return !llvm::any_of(
+ blockArgsToDetensor, [&](BlockArgument blockArgument) {
+ return blockArgument.getOwner() == &block &&
+ !typeConverter.isLegal(blockArgument.getType());
+ });
});
}
diff --git a/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
index 45ba726d5bf99..d2f989b561e44 100644
--- a/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
+++ b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
@@ -428,10 +428,7 @@ bool CastOp::areCastCompatible(TypeRange inputs, TypeRange outputs) {
auto aMemSpace = (aT) ? aT.getMemorySpace() : uaT.getMemorySpace();
auto bMemSpace = (bT) ? bT.getMemorySpace() : ubT.getMemorySpace();
- if (aMemSpace != bMemSpace)
- return false;
-
- return true;
+ return aMemSpace == bMemSpace;
}
return false;
diff --git a/mlir/lib/Dialect/StandardOps/Transforms/FuncConversions.cpp b/mlir/lib/Dialect/StandardOps/Transforms/FuncConversions.cpp
index 2cd22ef9aa2f7..0f07e547a7a39 100644
--- a/mlir/lib/Dialect/StandardOps/Transforms/FuncConversions.cpp
+++ b/mlir/lib/Dialect/StandardOps/Transforms/FuncConversions.cpp
@@ -146,10 +146,7 @@ bool mlir::isLegalForReturnOpTypeConversionPattern(Operation *op,
// ReturnLike operations have to be legalized with their parent. For
// return this is handled, for other ops they remain as is.
- if (op->hasTrait<OpTrait::ReturnLike>())
- return true;
-
- return false;
+ return op->hasTrait<OpTrait::ReturnLike>();
}
bool mlir::isNotBranchOpInterfaceOrReturnLikeOp(Operation *op) {
diff --git a/mlir/lib/Dialect/Vector/VectorUtils.cpp b/mlir/lib/Dialect/Vector/VectorUtils.cpp
index e799c96fd6b09..a6a0a25dcd89d 100644
--- a/mlir/lib/Dialect/Vector/VectorUtils.cpp
+++ b/mlir/lib/Dialect/Vector/VectorUtils.cpp
@@ -302,11 +302,7 @@ bool matcher::operatesOnSuperVectorsOf(Operation &op,
// This could be useful information if we wanted to reshape at the level of
// the vector type (but we would have to look at the compute and distinguish
// between parallel, reduction and possibly other cases.
- if (!ratio.hasValue()) {
- return false;
- }
-
- return true;
+ return ratio.hasValue();
}
bool mlir::isDisjointTransferIndices(VectorTransferOpInterface transferA,
diff --git a/mlir/lib/Transforms/NormalizeMemRefs.cpp b/mlir/lib/Transforms/NormalizeMemRefs.cpp
index d830b607904e7..477d0b6ec3048 100644
--- a/mlir/lib/Transforms/NormalizeMemRefs.cpp
+++ b/mlir/lib/Transforms/NormalizeMemRefs.cpp
@@ -92,13 +92,11 @@ void NormalizeMemRefs::runOnOperation() {
/// are satisfied will the value become a candidate for replacement.
/// TODO: Extend this for DimOps.
static bool isMemRefNormalizable(Value::user_range opUsers) {
- if (llvm::any_of(opUsers, [](Operation *op) {
- if (op->hasTrait<OpTrait::MemRefsNormalizable>())
- return false;
- return true;
- }))
- return false;
- return true;
+ return !llvm::any_of(opUsers, [](Operation *op) {
+ if (op->hasTrait<OpTrait::MemRefsNormalizable>())
+ return false;
+ return true;
+ });
}
/// Set all the calling functions and the callees of the function as not
diff --git a/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp b/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp
index dd97de1eebf1e..a4043b20ec505 100644
--- a/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp
+++ b/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp
@@ -54,8 +54,7 @@ static void getLoadAndStoreMemRefAccesses(Operation *opA,
static bool isDependentLoadOrStoreOp(Operation *op,
DenseMap<Value, bool> &values) {
if (auto loadOp = dyn_cast<AffineReadOpInterface>(op)) {
- return values.count(loadOp.getMemRef()) > 0 &&
- values[loadOp.getMemRef()] == true;
+ return values.count(loadOp.getMemRef()) > 0 && values[loadOp.getMemRef()];
}
if (auto storeOp = dyn_cast<AffineWriteOpInterface>(op)) {
return values.count(storeOp.getMemRef()) > 0;
diff --git a/mlir/lib/Transforms/Utils/LoopUtils.cpp b/mlir/lib/Transforms/Utils/LoopUtils.cpp
index 9a81f1d5d0763..1700d60a91730 100644
--- a/mlir/lib/Transforms/Utils/LoopUtils.cpp
+++ b/mlir/lib/Transforms/Utils/LoopUtils.cpp
@@ -1345,9 +1345,7 @@ static bool areInnerBoundsInvariant(AffineForOp forOp) {
}
return WalkResult::advance();
});
- if (walkResult.wasInterrupted())
- return false;
- return true;
+ return !walkResult.wasInterrupted();
}
// Gathers all maximal sub-blocks of operations that do not themselves
diff --git a/mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp b/mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp
index afff0faf0c2f8..d753378559a38 100644
--- a/mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp
+++ b/mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp
@@ -71,7 +71,7 @@ ConvertTosaNegateOp::matchAndRewrite(Operation *op,
double typeRangeMax = double(outputElementType.getStorageTypeMax() -
outputElementType.getZeroPoint()) *
outputElementType.getScale();
- bool narrowRange = outputElementType.getStorageTypeMin() == 1 ? true : false;
+ bool narrowRange = outputElementType.getStorageTypeMin() == 1;
auto dstQConstType = RankedTensorType::get(
outputType.getShape(),
diff --git a/mlir/test/lib/Dialect/Vector/TestVectorTransforms.cpp b/mlir/test/lib/Dialect/Vector/TestVectorTransforms.cpp
index 0d054720a61bc..6fc3d4a22fcb0 100644
--- a/mlir/test/lib/Dialect/Vector/TestVectorTransforms.cpp
+++ b/mlir/test/lib/Dialect/Vector/TestVectorTransforms.cpp
@@ -391,9 +391,7 @@ struct TestVectorToLoopPatterns
type.getNumElements() % multiplicity != 0)
return mlir::WalkResult::advance();
auto filterAlloc = [](Operation *op) {
- if (isa<arith::ConstantOp, memref::AllocOp, CallOp>(op))
- return false;
- return true;
+ return !isa<arith::ConstantOp, memref::AllocOp, CallOp>(op);
};
auto dependentOps = getSlice(op, filterAlloc);
// Create a loop and move instructions from the Op slice into the loop.
More information about the Mlir-commits
mailing list