[all-commits] [llvm/llvm-project] 81afd9: [mlir][arith] Add nneg to extui and uitofp. (#183165)

Erick Ochoa Lopez via All-commits all-commits at lists.llvm.org
Wed Feb 25 10:55:05 PST 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 81afd93a5153af024ef32aa8e597a5fc3b54c3a4
      https://github.com/llvm/llvm-project/commit/81afd93a5153af024ef32aa8e597a5fc3b54c3a4
  Author: Erick Ochoa Lopez <erick.ochoalopez at amd.com>
  Date:   2026-02-25 (Wed, 25 Feb 2026)

  Changed paths:
    M mlir/include/mlir/Conversion/ArithCommon/AttrToLLVMConverter.h
    M mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
    M mlir/include/mlir/Dialect/Arith/IR/ArithOpsInterfaces.td
    M mlir/lib/Conversion/ArithToLLVM/ArithToLLVM.cpp
    M mlir/lib/Dialect/Arith/IR/ArithCanonicalization.td
    M mlir/test/Conversion/ArithToLLVM/arith-to-llvm.mlir
    M mlir/test/Dialect/Arith/canonicalize.mlir
    M mlir/test/Dialect/Arith/ops.mlir

  Log Message:
  -----------
  [mlir][arith] Add nneg to extui and uitofp. (#183165)

This patchset adds missing the missing flag nneg (non-negative) to extui
and uitofp which denotes that the operand is known to be non-negative.
Semantics for this flag mirrors LLVM semantics.

[From:](https://discourse.llvm.org/t/rfc-add-zext-nneg-flag/73914) 

> If the nneg flag is set, and the zext argument is negative, the result
is a poison value.
> A corollary is that replacing a zext nneg with sext is a refinement.


[and](https://discourse.llvm.org/t/rfc-support-nneg-flag-with-uitofp/77988):

> uitofp nneg iN %x to fM returns poison if %x is negative
> A corollary is that uitofp nneg iN %x to fM is equivilent to sitofp iN
%x to fM.

* Adds ArithNonNegFlagInterface
* Adds AttrConvertNonNegToLLVM 
* Updates definitions of arith.extui and arith.uitofp to declare
ArithNonNegFlagInterface
* Updates canonicalization patterns to propagate nneg where applicable
* Adds roundtrip, lowering, and canonicalization tests.

Assisted-by: claude



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list