feat(joinir): Phase 213 AST-based if-sum lowerer for Pattern 3

Implement dual-mode architecture for Pattern 3 (Loop with If-Else PHI):

- Add is_simple_if_sum_pattern() detection helper
  - Detects 1 CounterLike + 1-2 AccumulationLike carrier patterns
  - Unit tests for various carrier compositions

- Add dual-mode dispatch in Pattern3 lowerer
  - ctx.is_if_sum_pattern() branches to AST-based vs legacy PoC
  - Legacy mode preserved for backward compatibility

- Create loop_with_if_phi_if_sum.rs (~420 lines)
  - AST extraction: loop condition, if condition, updates
  - JoinIR generation: main, loop_step, k_exit structure
  - Helper functions: extract_loop_condition, extract_if_condition, etc.

- Extend PatternPipelineContext for Pattern 3
  - is_if_sum_pattern() detection using LoopUpdateSummary
  - extract_if_statement() helper for body analysis

Note: E2E RC=2 not yet achieved due to pre-existing Pattern 3
pipeline issue (loop back branch targets wrong block). This
affects both if-sum and legacy modes. Fix planned for Phase 214.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-10 00:54:46 +09:00
parent 8394018694
commit 338d1aecf1
7 changed files with 810 additions and 28 deletions

View File

@ -58,6 +58,7 @@ pub(crate) mod loop_view_builder; // Phase 33-23: Loop lowering dispatch
pub mod loop_with_break_minimal; // Phase 188-Impl-2: Pattern 2 minimal lowerer
pub mod loop_with_continue_minimal; // Phase 195: Pattern 4 minimal lowerer
pub mod loop_with_if_phi_minimal; // Phase 188-Impl-3: Pattern 3 minimal lowerer
pub mod loop_with_if_phi_if_sum; // Phase 213: Pattern 3 AST-based if-sum lowerer
pub mod simple_while_minimal; // Phase 188-Impl-1: Pattern 1 minimal lowerer
pub mod min_loop;
pub mod skip_ws;