[all-commits] [llvm/llvm-project] 2e637d: [flang] Canonicalize redundant pointer converts. (...

Slava Zakharin via All-commits all-commits at lists.llvm.org
Tue Jan 7 08:36:04 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2e637dbbb8bc9a41f8eabd1df347ca2559b1abd7
      https://github.com/llvm/llvm-project/commit/2e637dbbb8bc9a41f8eabd1df347ca2559b1abd7
  Author: Slava Zakharin <szakharin at nvidia.com>
  Date:   2025-01-07 (Tue, 07 Jan 2025)

  Changed paths:
    M flang/include/flang/Optimizer/Dialect/CanonicalizationPatterns.td
    M flang/lib/Optimizer/Dialect/FIROps.cpp
    M flang/test/Fir/convert-fold.fir
    M flang/test/Lower/array-substring.f90
    M flang/test/Lower/vector-subscript-io.f90

  Log Message:
  -----------
  [flang] Canonicalize redundant pointer converts. (#121864)

This patch adds a canonicalization pattern for optimizing redundant
"pointer" fir.converts. Such converts prevent the StackArrays pass
to recognize fir.freemem for the corresponding fir.allocmem, e.g.:
```
    %69 = fir.allocmem !fir.array<2xi32>
    %71:2 = hlfir.declare %69(%70) {uniq_name = ".tmp.arrayctor"} :
        (!fir.heap<!fir.array<2xi32>>, !fir.shape<1>) ->
        (!fir.heap<!fir.array<2xi32>>, !fir.heap<!fir.array<2xi32>>)
    %95 = fir.convert %71#1 :
        (!fir.heap<!fir.array<2xi32>>) -> !fir.ref<!fir.array<2xi32>>
    %100 = fir.convert %95 :
        (!fir.ref<!fir.array<2xi32>>) -> !fir.heap<!fir.array<2xi32>>
    fir.freemem %100 : !fir.heap<!fir.array<2xi32>>
```
I found this in `tonto`, but the change does not affect performance at all.
Anyway, it looks like a reasonable thing to do, and it makes easier
to compare the performance profiles with other compilers'.



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