[Mlir-commits] [mlir] [mlir][arith] Add nneg to extui and uitofp. (PR #183165)

Jakub Kuderski llvmlistbot at llvm.org
Wed Feb 25 06:38:18 PST 2026


================
@@ -1172,14 +1172,19 @@ def Arith_RemFOp : Arith_FloatBinaryOp<"remf"> {
 // ExtUIOp
 //===----------------------------------------------------------------------===//
 
-def Arith_ExtUIOp : Arith_IToICastOp<"extui"> {
+def Arith_ExtUIOp :
+    Arith_IToICastOp<"extui", [DeclareOpInterfaceMethods<ArithNonNegFlagInterface>]> {
   let summary = "integer zero extension operation";
   let description = [{
     The integer zero extension operation takes an integer input of
     width M and an integer destination type of width N. The destination
     bit-width must be larger than the input bit-width (N > M).
     The top-most (N - M) bits of the output are filled with zeros.
 
+    This op supports an `nneg` flag. If the flag is present, the operand
+    is known to be non-negative, i.e. the sign bit is zero. This allows
+    the zero extension to be treated as a sign extension.
----------------
kuhar wrote:

I find this description very awkward. Since this is `extUI`, we assume to be operating on unsigned values, so there's not sign bit really and no negative values...

Maybe we can say this instead.

```suggestion
    When the `nneg` flag is present, the operand is known to have
    the most significant bit set to 0. In this case, zero extension is
    equivalent to sign extension.
```

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


More information about the Mlir-commits mailing list