[all-commits] [llvm/llvm-project] 90f1a0: [mlir][Transforms] Dialect conversion: Align handl...

Matthias Springer via All-commits all-commits at lists.llvm.org
Thu Sep 12 02:56:58 PDT 2024


  Branch: refs/heads/users/matthias-springer/replace_op_source_mat
  Home:   https://github.com/llvm/llvm-project
  Commit: 90f1a0e50c7fde08a66d25ac7b3ca665fd92e0ab
      https://github.com/llvm/llvm-project/commit/90f1a0e50c7fde08a66d25ac7b3ca665fd92e0ab
  Author: Matthias Springer <mspringer at nvidia.com>
  Date:   2024-09-12 (Thu, 12 Sep 2024)

  Changed paths:
    M mlir/lib/Transforms/Utils/DialectConversion.cpp
    M mlir/test/Transforms/test-legalize-erased-op-with-uses.mlir

  Log Message:
  -----------
  [mlir][Transforms] Dialect conversion: Align handling of dropped values

Handle dropped block arguments and dropped op results in the same way: build a source materialization (that may fold away if unused). This simplifies the code base a bit and makes it possible to merge `legalizeConvertedArgumentTypes` and `legalizeConvertedOpResultTypes` in a future commit. These two functions are almost doing the same thing now.

This commit also fixes a bug where circular materializations were built, e.g.:
```
%0 = "builtin.unrealized_conversion_cast"(%1) : (!a) -> !b
%1 = "builtin.unrealized_conversion_cast"(%0) : (!b) -> !a
// No further uses of %0, %1.
```

This happened when:
1. An op was erased. (No replacement values provided.)
2. A conversion pattern for another op builds a replacement value (first cast op) during `remapValues`, but that SSA value is not used during the pattern application.
3. During the finalization phase, `legalizeConvertedOpResultTypes` thinks that the erased op is alive because of the cast op that was built in Step 2. It builds a cast from that replacement value to the original type.
4. During the commit phase, all uses of the original op are repalced with the casted value produced in Step 3. We have generated circular IR.


  Commit: fa5f8c627137e62fe99c1efa6e61d5de3d49177b
      https://github.com/llvm/llvm-project/commit/fa5f8c627137e62fe99c1efa6e61d5de3d49177b
  Author: Matthias Springer <mspringer at nvidia.com>
  Date:   2024-09-12 (Thu, 12 Sep 2024)

  Changed paths:
    M mlir/lib/Transforms/Utils/DialectConversion.cpp

  Log Message:
  -----------
  Remove `changedResults`


Compare: https://github.com/llvm/llvm-project/compare/b6d5cec24215...fa5f8c627137

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