[Mlir-commits] [mlir] [mlir][Affine] Add nuw/nsw to lowering of affine ops. (PR #121535)

Krzysztof Drewniak llvmlistbot at llvm.org
Thu Jan 2 23:42:08 PST 2025


================
@@ -93,8 +95,9 @@ class AffineApplyExpander
     Value zeroCst = builder.create<arith::ConstantIndexOp>(loc, 0);
     Value isRemainderNegative = builder.create<arith::CmpIOp>(
         loc, arith::CmpIPredicate::slt, remainder, zeroCst);
-    Value correctedRemainder =
-        builder.create<arith::AddIOp>(loc, remainder, rhs);
+    Value correctedRemainder = builder.create<arith::AddIOp>(
----------------
krzysz00 wrote:

I'm pretty sure this addition is not `nuw`.

Specifically, consider `lhs = -5` and `rhs = 3`. Then, `remainder == -2`, which means that we're doing `correctedRemainder = add nuw nsw -2, 3`, which is not `nuw`

https://github.com/llvm/llvm-project/pull/121535


More information about the Mlir-commits mailing list