feat(joinir): Phase 212.5 Structural if detection for Pattern 3 routing
Phase 212.5 で発見した「ループ内 if が Pattern 1 に誤ルーティング」問題を修正。
構造ベース if 検出により、単一キャリアの if-update パターンも Pattern 3 へ正しくルーティング可能に。
## Changes
### 1. AST Feature Extractor (ast_feature_extractor.rs)
- **Added**: `detect_if_in_body()` function
- Detects ANY if statement in loop body (not just if-else)
- Enables structural if detection vs carrier-count heuristic
- **Modified**: `extract_features()`
- Uses `detect_if_in_body()` for `has_if` detection
- Removes dependency on carrier count for if detection
### 2. Loop Pattern Classification (loop_pattern_detection/mod.rs)
- **Modified**: `classify()` function
- Pattern 3: `carrier_count > 1` → `has_if && carrier_count >= 1`
- Pattern 1: `!has_if_else_phi` → `!has_if`
- Now routes single-carrier if-update patterns to Pattern 3
## Verification
Test case: `apps/tests/phase212_if_sum_min.hako`
### Before (Phase 212):
- ❌ Routed to Pattern 1 (wrong)
- ❌ if statement disappeared in MIR
- ❌ Carriers: only `i` (sum missing)
### After (Phase 212.5):
- ✅ Routed to Pattern 3 (correct!)
- ✅ MIR contains PHI nodes: `%31 = phi [%25, bb9], [%29, bb10]`
- ✅ Carriers: `i`, `sum`, `count` detected
Pattern routing log:
```
[joinir/pattern3] Generated JoinIR for Loop with If-Else PHI
[joinir/pattern3] Carriers: i (counter), sum (accumulator), count (counter)
```
## Known Limitation
Pattern 3 lowerer (`lower_loop_with_if_phi_pattern`) is currently a
test-only hardcoded implementation:
- Loop condition: `i <= 5` (hardcoded)
- If condition: `i % 2 == 1` (hardcoded)
- Update logic: `sum + i` (hardcoded)
This is why `phase212_if_sum_min.hako` produces RC=0 instead of RC=2.
Pattern routing is complete; AST-based lowerer generalization is Phase 213.
## Documentation
- `docs/development/current/main/phase212-5-implementation-complete.md`
- Complete implementation report with verification details
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>