[flang][hlfir] avoid useless LHS temporaries inside WHERE
authorJean Perier <jperier@nvidia.com>
Wed, 5 Jul 2023 12:26:04 +0000 (14:26 +0200)
committerJean Perier <jperier@nvidia.com>
Wed, 5 Jul 2023 12:26:41 +0000 (14:26 +0200)
commite52a6d7784adbcb98b17af7943c69c854aa7b10f
treee8cff22376e277610decaaca962951d8e9bbd0b3
parent3003da71540bb8483615e18f8ab379da39fa4512
[flang][hlfir] avoid useless LHS temporaries inside WHERE

The need to save LHS addresses on a stack before doing an assignment
is very limited: it is only really needed for forall and vectore
subscripted LHS where the LHS cannot be computed as a descriptor.

The previous current WHERE codegen was creating address stacks for
LHS element addresses when the LHS evaluation conflicts with the
assignment (may depend on the LHS value). This is not needed
since the computed array designator for the LHS is already "saved"
before the assignment from an SSA point of view.

This patch prevents LHS temporary stack from being created outside
of forall and vector subscripted assignments.

Differential Revision: https://reviews.llvm.org/D154418
flang/lib/Optimizer/HLFIR/Transforms/ScheduleOrderedAssignments.cpp
flang/test/HLFIR/order_assignments/where-scheduling.f90