[all-commits] [llvm/llvm-project] fc2c8f: [flang][hlfir] Do not reuse hlfir.expr mask when s...
jeanPerier via All-commits
all-commits at lists.llvm.org
Tue Jun 27 23:36:02 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: fc2c8fed0b47217814e2b917e94d2d8b185c35a2
https://github.com/llvm/llvm-project/commit/fc2c8fed0b47217814e2b917e94d2d8b185c35a2
Author: Jean Perier <jperier at nvidia.com>
Date: 2023-06-28 (Wed, 28 Jun 2023)
Changed paths:
M flang/include/flang/Optimizer/Builder/TemporaryStorage.h
M flang/lib/Optimizer/HLFIR/Transforms/LowerHLFIROrderedAssignments.cpp
M flang/test/HLFIR/order_assignments/impure-where.fir
M flang/test/HLFIR/order_assignments/inlined-stack-temp.fir
A flang/test/HLFIR/order_assignments/saving-mask-and-rhs.fir
M flang/test/HLFIR/order_assignments/user-defined-assignment.fir
Log Message:
-----------
[flang][hlfir] Do not reuse hlfir.expr mask when saving RHS.
In WHERE and masked FORALL assignment, both the mask and the
RHS may need to be saved in some temporary storage before evaluating
the assignment.
The code was trying to "optimize" that case when evaluating the RHS
by not fetching the mask temporary that was just created, but in simple
cases of WHERE construct where the evaluated mask is an hlfir.expr,
this caused the hlfir.expr to be both used in an hlfir.associate and
later in an hlfir.apply to create the fir.if to mask the RHS evaluation.
This double usage prevents codegen from inlining the hlfir.expr at the
hlfir.apply, and from "moving" the hlfir.expr storage into the temp
during hlfir.associate bufferization. So this is pessimizing the code:
this would lead to created two mask array temporary storages
This was caught by the unexpectedly high number of "not yet implemented:
hlfir.associate of hlfir.expr with more than one use" that were firing.
Use the mask temporary instead (the hlfir.associate result) when possible.
Some temporary (the "inlined stack") do not support fetching and pushing
in the same run (a single counter is used to keep track of the fetching
and pushing position). Add a canBeFetchedAfterPush() for safety,
but this limitation is anyway not relevant for hlfir.expr since the
inlined stack is only used to save "trivial" scalars.
Also update the temporary storage name to only indicate "forall" if
the top level construct is a FORALL. This is not a very precise name,
but it should at least give a correct context to indicate in the IR
why some temporary array storage was created.
Differential Revision: https://reviews.llvm.org/D153880
More information about the All-commits
mailing list