[all-commits] [llvm/llvm-project] 25f5e9: [flang] optimize WHERE with identical and disjoint...

jeanPerier via All-commits all-commits at lists.llvm.org
Tue Feb 10 02:35:38 PST 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 25f5e9732784a9feec563c99ffcaa2b30b00ec72
      https://github.com/llvm/llvm-project/commit/25f5e9732784a9feec563c99ffcaa2b30b00ec72
  Author: jeanPerier <jperier at nvidia.com>
  Date:   2026-02-10 (Tue, 10 Feb 2026)

  Changed paths:
    M flang/lib/Optimizer/HLFIR/Transforms/LowerHLFIROrderedAssignments.cpp
    M flang/lib/Optimizer/HLFIR/Transforms/ScheduleOrderedAssignments.cpp
    M flang/lib/Optimizer/HLFIR/Transforms/ScheduleOrderedAssignments.h
    M flang/lib/Optimizer/Passes/Pipelines.cpp
    M flang/test/HLFIR/order_assignments/inlined-stack-temp.fir
    A flang/test/HLFIR/order_assignments/where-array-sections.f90
    M flang/test/HLFIR/order_assignments/where-fusing-scheduling.f90
    M flang/test/HLFIR/order_assignments/where-scheduling.f90

  Log Message:
  -----------
  [flang] optimize WHERE with identical and disjoint array sections (#180279)

Improve `ScheduleOrderedAssignments` to avoid creating temporary storage
for masks in `WHERE` constructs when the mask modification is "aligned"
with the assignment (e.g., `where(a(i)>0) a(i)=...`).

- Identify "aligned" conflicts (identical array elements accessed in
order) using the `ArraySectionAnalyzer` that is extracted from
OptimizedBufferization.
- Defer saving regions with aligned conflicts, allowing fusion if
possible.
- Implement retroactive saving: if a region was modified in a previous
run (fused via aligned conflict) but is needed by a later split run,
insert a `SaveEntity` action before the modifying run.
- Use `std::list` for the schedule to support stable iterators for run
insertion.
- Update tests to verify fewer temporaries and correct retroactive
saves.
- Update flang pipeline at O2 and more to try fusing assignments in
WHERE/FORALL. This allows maximizing the chances that mask temps are not
needed (because a mask variable cannot be reused in a later run/loop
nest if it was modified even if all the accesses are in order, being in
order only matter for accesses generated inside the same loop nest).

This fixes suboptimal code generation where temporaries were created
unnecessarily for common patterns like `where (x > 0) x = ...`.



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