[Mlir-commits] [mlir] [mlir][NFC] Simplify constant checks with isZeroIndex and isOneIndex. (PR #139340)
Han-Chung Wang
llvmlistbot at llvm.org
Mon May 12 10:44:12 PDT 2025
================
@@ -28,6 +28,10 @@ namespace mlir {
/// with attribute with value `0`.
bool isZeroIndex(OpFoldResult v);
+/// Return true if `v` is an IntegerAttr with value `1` of a ConstantIndexOp
+/// with attribute with value `1`.
+bool isOneIndex(OpFoldResult v);
----------------
hanhanW wrote:
IMHO, I'd prefer having all of them. I can see the value of having `isConstantIntValue`, but I fundamentally don't like template. Because it usually makes code hard to maintain and debug. It may not be the case in this example because we are not doing template metaprogramming, but I'd avoid it when possible.
The other point is that `isOneIndex` and `isZeroIndex` are more common in those offsets/sizes/strides checks, and the names are more explicit, IMO. How about having all of them?
https://github.com/llvm/llvm-project/pull/139340
More information about the Mlir-commits
mailing list