================
@@ -2941,22 +2941,27 @@ mlir::LogicalResult cir::FuncOp::verify() {
// AddOp / SubOp
//===----------------------------------------------------------------------===//
-// The integer-only type constraint on these ops makes the nsw/nuw/sat flag
-// type checks unnecessary. Only the mutual-exclusivity between nsw/nuw and
-// sat needs to be verified.
+static LogicalResult verifyAddSubFlags(Operation *op, Type type, bool nsw,
+ bool nuw, bool sat) {
+ if ((nsw && nuw) || (sat && (nsw || nuw)))
+ return op->emitOpError()
+ << "the nsw, nuw, and saturated flags are mutually exclusive";
+ if (nsw && !cir::isSIntOrVectorOfSIntType(type))
----------------
bcardosolopes wrote:
These two make the `(nsw && nuw)` clause above unreachable. An integer type is
either signed or unsigned, so if both flags are set one of these always fires
first, and it fires with a better message than "mutually exclusive".
Worth dropping the `nsw && nuw` half and keeping the `sat` half, otherwise the
error text promises a rule that this function never actually gets to apply. It
also makes the `poison |=` accumulation in `foldAddSubConst` read as if both
can be live at once, when it can only ever be one.
https://github.com/llvm/llvm-project/pull/218398
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits