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

@ -15,11 +15,14 @@ Related:
- 次フェーズ: Phase 257`last_index_of/2` の reverse scan + early return loop
- 直近の完了:
- P1.13: Pattern2 boundary entry_param_mismatch 根治(`join_module.entry.params` SSOT 化)
- P1.13.5= Phase 256.8.5: Pattern4/6/7 でも `boundary.join_inputs``join_module.entry.params` SSOT に統一hardcoded ValueId/PARAM_MIN を撤去)
- P1.10: DCE が `jump_args` 参照を保持し、`instruction_spans` と同期するよう修正(回帰テスト追加)
- P1.7: SSA undef`%49/%67`根治continuation 関数名の SSOT 不一致)
- P1.6: pipeline contract checks を `run_all_pipeline_checks()` に集約
- 次の作業: Phase 257last_index_of pattern - loop with return support
- 設計メモChatGPT Pro 相談まとめ): `docs/development/current/main/investigations/phase-256-joinir-contract-questions.md`
- Known issue非ブロッカー:
- Pattern7 integration smoke で `phi predecessor mismatch` が残っている(今回の boundary SSOT 統一とは独立)
---