[all-commits] [llvm/llvm-project] 3c585b: [flang] Allow `VariableAssignBufferization` to han...
Kareem Ergawy via All-commits
all-commits at lists.llvm.org
Tue Nov 12 03:03:05 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 3c585bdd3c53538b092ec36d81b038e43f605325
https://github.com/llvm/llvm-project/commit/3c585bdd3c53538b092ec36d81b038e43f605325
Author: Kareem Ergawy <kareem.ergawy at amd.com>
Date: 2024-11-12 (Tue, 12 Nov 2024)
Changed paths:
M flang/lib/Optimizer/HLFIR/Transforms/OptimizedBufferization.cpp
M flang/test/HLFIR/opt-bufferization.fir
Log Message:
-----------
[flang] Allow `VariableAssignBufferization` to handle `hlfir::ExprType` (#115136)
Given the following input:
```fortran
1. subroutine ComputeDifferencesKernel
2. implicit none
3. integer :: i
4. integer, dimension(1) :: a
5.
6. do i = 1, 10
7. a = [ i ]
8. end do
9. end subroutine ComputeDifferencesKernel
```
Currently, the assignment in line 7 ends up as a call to the Fortran
runtime function: `AAssign` since the corresponding `hlfir.assign` is
not optimized away by `VariableAssignBufferization`. The reason this
assignment is not optimized away is that `VariableAssignBufferization`
does not match whenever the RHS of the assignment is a `hlfir.expr`
value. However, this behavior is introduced only to prevent clashes
between `VariableAssignBufferization` and `ElementalAssignBufferization`
which optimizes away assignemnts that result from `hlfir.elemental` ops.
This patch relaxes that restriction by checking whether the RHS of an
`hlfir.assign` is the result of `hlfir.elemental` or not. If not, we can
safely proceed with `VariableAssignBufferization`.
Note that in the above example, we won't get a `hlfir.elemental` in the
IR. We would get if we changed line 7 to something like:
```fortran
7. a = [ i ] + b
```
In which case, `ElementalAssignBufferization` will kick in instead.
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