[all-commits] [llvm/llvm-project] c56e7f: [mlir][arith] Canonicalize sitofp(truncf) -> sitof...

Christian Sigg via All-commits all-commits at lists.llvm.org
Mon May 19 06:07:51 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c56e7f22f06ac52d2ef3ea487910ab60a1256138
      https://github.com/llvm/llvm-project/commit/c56e7f22f06ac52d2ef3ea487910ab60a1256138
  Author: Christian Sigg <csigg at google.com>
  Date:   2025-05-19 (Mon, 19 May 2025)

  Changed paths:
    M mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
    M mlir/lib/Dialect/Arith/IR/ArithCanonicalization.td
    M mlir/lib/Dialect/Arith/IR/ArithOps.cpp
    M mlir/test/Dialect/Arith/canonicalize.mlir

  Log Message:
  -----------
  [mlir][arith] Canonicalize sitofp(truncf) -> sitofp, and uitofp. (#139925)

Add a canonicalization patterns that simplifies `truncf(sitofp(x))` to
`sitofp(x)` and `truncf(uitofp(x))` to `uitofp(x)`, if truncf has default rounding mode.

This assumes that the destination type of truncf is representable by the
intermediate type.

Note that the truncf semantics requires that the destination type is
narrower than the source type, so this is true for all types I can
possibly think of, but one could probably construct an artificial
counter example.

Somewhat related: https://github.com/llvm/llvm-project/pull/128096



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