[all-commits] [llvm/llvm-project] 8f3ad1: [flang][Transforms] Add LiftSCFWhileToSCFFor pass
Kareem Ergawy via All-commits
all-commits at lists.llvm.org
Fri Jul 31 06:16:04 PDT 2026
Branch: refs/heads/users/ergawy/lift-scf-while-to-scf-for
Home: https://github.com/llvm/llvm-project
Commit: 8f3ad1f08e1d2ad8248f19a238660ff8d5fbe3d2
https://github.com/llvm/llvm-project/commit/8f3ad1f08e1d2ad8248f19a238660ff8d5fbe3d2
Author: ergawy <kareem.ergawy at gmail.com>
Date: 2026-07-31 (Fri, 31 Jul 2026)
Changed paths:
M flang/include/flang/Optimizer/Transforms/Passes.td
M flang/lib/Optimizer/Transforms/CMakeLists.txt
A flang/lib/Optimizer/Transforms/LiftSCFWhileToSCFFor.cpp
A flang/test/Fir/LiftSCFWhileToSCFFor/iv-next-body-use.mlir
A flang/test/Fir/LiftSCFWhileToSCFFor/step-gt-one.mlir
A flang/test/Fir/LiftSCFWhileToSCFFor/step-one.mlir
A flang/test/Fir/LiftSCFWhileToSCFFor/two-iter-args.mlir
Log Message:
-----------
[flang][Transforms] Add LiftSCFWhileToSCFFor pass
Introduces `--lift-scf-while-to-scf-for`, which walks every scf.while
produced by upstream `lift-cf-to-scf` and, when the canonical
"trip-counter + induction-variable" shape is recognized, rewrites the
loop as scf.for. Other loop-carried before-args are passed through as
iter_args. Loops that do not match (data-dependent updates, used
results, non-positive IV step, etc.) are left untouched and a
diagnostic is emitted to stderr.
Recognition collects a LoopInfo describing the loop:
- trip counter: candidate the gating cmp uses, must have step -1
- induction variable: the single non-trip affine recurrence, must
have positive step (negative step bails for now)
- iter_args: any other before-args that pass through unchanged
Rewrite materializes `ub_excl = ivInit + tripInit * ivStep` before
the scf.while, casts lb/ub/step to index (so the resulting scf.for
is compatible with downstream affine conversion), and clones the
body from the predicate scf.if's continues branch. The IV recurrence
result is remapped to `forIV + step` materialized at the top of the
body so cloned ops referencing the next-iteration value keep working.
Companion to lift-cf-to-scf for rebuilding counted loops from
recovered do-while loops.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply at anthropic.com>
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