Cleanup assertion logic (#14510)
Explicitly separate assertion check vs. messages
diff --git a/compiler/src/iree/compiler/Codegen/LLVMCPU/KernelDispatch.cpp b/compiler/src/iree/compiler/Codegen/LLVMCPU/KernelDispatch.cpp
index 215af71..1c3c0a1 100644
--- a/compiler/src/iree/compiler/Codegen/LLVMCPU/KernelDispatch.cpp
+++ b/compiler/src/iree/compiler/Codegen/LLVMCPU/KernelDispatch.cpp
@@ -608,10 +608,8 @@
int64_t numLoops = lbs.size();
assert(numLoops == minTileSizes.size() && maxTileSizes.size() == numLoops &&
"expected as many min/max tile sizes as number of loops");
- assert(
- vectorSizeHints.empty() ||
- vectorSizeHints.size() == numLoops &&
- "vector size hints should be empty or equal to the number of loops");
+ assert((vectorSizeHints.empty() || vectorSizeHints.size() == numLoops) &&
+ "vector size hints should be empty or equal to the number of loops");
// Only set values when the loop is partitionable.
SmallVector<int64_t> adjustedMinTileSizes(numLoops, 0);
diff --git a/compiler/src/iree/compiler/Codegen/TransformStrategies/GPU/Common.cpp b/compiler/src/iree/compiler/Codegen/TransformStrategies/GPU/Common.cpp
index 3f006c6..f159017 100644
--- a/compiler/src/iree/compiler/Codegen/TransformStrategies/GPU/Common.cpp
+++ b/compiler/src/iree/compiler/Codegen/TransformStrategies/GPU/Common.cpp
@@ -82,7 +82,7 @@
int64_t mlir::iree_compiler::gpu::adjustNumberOfWarpsForBlockShuffle(
int64_t numWarpsToUse, int64_t bitWidth) {
// Try to scale down the number of warps to use 32b elements in warp shuffles.
- assert((bitWidth & bitWidth - 1) == 0 && "bitWidth must be a power of 2");
+ assert(((bitWidth & (bitWidth - 1)) == 0) && "bitWidth must be a power of 2");
int64_t factor;
for (factor = scaleUpByBitWidth(1, bitWidth); factor > 1; factor >>= 1)
if (numWarpsToUse % factor == 0)
diff --git a/compiler/src/iree/compiler/Dialect/HAL/Conversion/ConversionTarget.cpp b/compiler/src/iree/compiler/Dialect/HAL/Conversion/ConversionTarget.cpp
index f1a1f74..02785f5 100644
--- a/compiler/src/iree/compiler/Dialect/HAL/Conversion/ConversionTarget.cpp
+++ b/compiler/src/iree/compiler/Dialect/HAL/Conversion/ConversionTarget.cpp
@@ -55,9 +55,10 @@
// Check that any type that should have been mapped to buffer view was.
// This is just to catch conflicts in type conversions that may sneak in
// during development.
- assert(!HALTypeConverter::shouldConvertToBufferView(srcOperand.getType()) ||
- dstOperand.getType().isa<IREE::HAL::BufferViewType>() &&
- "expect that tensors have been mapped to buffer views");
+ assert(
+ (!HALTypeConverter::shouldConvertToBufferView(srcOperand.getType()) ||
+ dstOperand.getType().isa<IREE::HAL::BufferViewType>()) &&
+ "expect that tensors have been mapped to buffer views");
state.addOperands({dstOperand});
}
for (auto resultType : srcOp->getResultTypes()) {