feat(pattern6): support reverse scan for last_index_of

Extend Pattern6 (ScanWithInit) to handle both forward and reverse scans:
- Forward: i=0, loop(i < len), i=i+1 (existing)
- Reverse: i=len-1, loop(i >= 0), i=i-1 (NEW)

Implementation:
- Added ScanDirection enum (Forward/Reverse)
- Updated extract_scan_with_init_parts() to detect both patterns
- Created lower_scan_with_init_reverse() lowerer
- Pattern6 now selects appropriate lowerer based on scan direction

Files modified:
- src/mir/builder/control_flow/joinir/patterns/pattern6_scan_with_init.rs
- src/mir/join_ir/lowering/scan_with_init_reverse.rs (new)
- src/mir/join_ir/lowering/mod.rs

Known issue (pre-existing):
- PHI predecessor mismatch bug exists in Pattern6 (both forward and reverse)
- This bug existed BEFORE Phase 257 P0 implementation
- Out of scope for Phase 257 P0 - will be addressed separately

Phase 257 P0
This commit is contained in:
2025-12-20 20:28:41 +09:00
parent 8394b2d6fd
commit 9ba89bada2
6 changed files with 467 additions and 25 deletions

View File

@ -62,7 +62,8 @@
- P1.5-DBG: boundary entry params の契約チェックを追加VM実行前 fail-fast
- P1.6: 契約チェックの薄い集約 `run_all_pipeline_checks()` を導入pipeline の責務を縮退)。
- P1.13: Pattern2 boundary entry params を `join_module.entry.params` SSOT へ寄せたValueId 推測生成の撤去)。
- P1.13.5: Boundary SSOT 統一Pattern4/6/7 横展開 + 共通ヘルパ `get_entry_function()` 抽出)。
- P1.13.5= Phase 256.8.5: Boundary SSOT 統一Pattern4/6/7 横展開 + hardcoded ValueId/PARAM_MIN 撤去)。
- Known issue非ブロッカー: Pattern7 integration smoke の `phi predecessor mismatch` は残存(今回の修正とは独立)。
## 2025-12-20Phase 257last_index_of early return loop🔜