nyash-codex
aeb6282c2d
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>
2025-12-09 23:35:57 +09:00
..
2025-12-03 13:42:05 +09:00
2025-12-07 21:02:20 +09:00
2025-12-07 01:45:03 +09:00
2025-09-17 10:58:12 +09:00
2025-12-04 10:52:10 +09:00
2025-12-05 16:08:56 +09:00
2025-12-04 06:02:03 +09:00
2025-12-04 06:02:03 +09:00
2025-12-03 13:59:06 +09:00
2025-12-05 23:33:06 +09:00
2025-12-05 23:33:06 +09:00
2025-12-08 04:14:28 +09:00
2025-12-02 21:52:18 +09:00
2025-12-04 15:00:45 +09:00
2025-12-04 06:02:03 +09:00
2025-12-09 19:39:01 +09:00
2025-12-08 06:14:03 +09:00
2025-12-08 00:09:45 +09:00
2025-12-03 14:33:04 +09:00
2025-12-06 16:22:38 +09:00
2025-12-08 18:36:13 +09:00
2025-12-04 17:47:19 +09:00
2025-12-06 03:30:03 +09:00
2025-12-06 03:30:03 +09:00
2025-11-27 17:05:46 +09:00
2025-12-05 14:41:24 +09:00
2025-12-07 21:02:20 +09:00
2025-12-07 21:02:20 +09:00
2025-12-07 21:02:20 +09:00
2025-12-07 21:02:20 +09:00
2025-12-07 21:02:20 +09:00
2025-12-07 21:02:20 +09:00
2025-12-07 21:02:20 +09:00
2025-12-07 21:02:20 +09:00
2025-12-07 21:02:20 +09:00
2025-12-07 21:02:20 +09:00
2025-12-07 21:02:20 +09:00
2025-12-07 21:02:20 +09:00
2025-12-07 21:02:20 +09:00
2025-12-08 00:09:45 +09:00
2025-12-07 21:02:20 +09:00
2025-12-07 21:02:20 +09:00
2025-12-07 21:02:20 +09:00
2025-11-29 15:57:14 +09:00
2025-11-29 15:57:14 +09:00
2025-11-29 15:57:14 +09:00
2025-11-30 08:54:18 +09:00
2025-12-02 09:45:54 +09:00
2025-11-30 10:10:45 +09:00
2025-12-02 10:19:07 +09:00
2025-12-02 11:16:01 +09:00
2025-12-02 12:36:28 +09:00
2025-12-02 19:37:01 +09:00
2025-12-02 19:37:01 +09:00
2025-12-02 19:37:01 +09:00
2025-12-02 19:37:01 +09:00
2025-12-02 20:18:13 +09:00
2025-12-02 20:18:13 +09:00
2025-12-02 20:18:13 +09:00
2025-12-02 20:30:22 +09:00
2025-12-02 20:18:13 +09:00
2025-12-02 19:37:01 +09:00
2025-12-02 19:37:01 +09:00
2025-12-02 21:09:15 +09:00
2025-12-02 21:09:15 +09:00
2025-12-03 18:16:49 +09:00
2025-12-03 19:37:32 +09:00
2025-12-03 19:37:32 +09:00
2025-12-03 19:22:55 +09:00
2025-12-03 21:32:14 +09:00
2025-12-03 21:12:37 +09:00
2025-12-03 22:03:16 +09:00
2025-12-04 03:35:25 +09:00
2025-12-04 03:58:02 +09:00
2025-12-04 04:30:30 +09:00
2025-12-04 04:30:30 +09:00
2025-12-04 04:42:32 +09:00
2025-12-04 06:26:59 +09:00
2025-12-04 04:42:32 +09:00
2025-12-04 04:42:32 +09:00
2025-12-04 06:02:03 +09:00
2025-12-04 06:02:03 +09:00
2025-12-04 06:02:03 +09:00
2025-12-04 06:17:10 +09:00
2025-12-04 06:24:03 +09:00
2025-12-04 06:02:03 +09:00
2025-12-04 06:02:03 +09:00
2025-12-04 06:02:03 +09:00
2025-12-04 11:04:29 +09:00
2025-12-04 10:57:13 +09:00
2025-12-04 11:28:55 +09:00
2025-12-04 11:44:55 +09:00
2025-12-04 12:06:34 +09:00
2025-12-04 12:22:55 +09:00
2025-12-04 12:27:44 +09:00
2025-12-04 13:07:12 +09:00
2025-12-04 13:07:12 +09:00
2025-12-04 13:33:44 +09:00
2025-12-04 13:54:45 +09:00
2025-12-04 14:10:51 +09:00
2025-12-04 14:19:48 +09:00
2025-12-04 15:15:27 +09:00
2025-12-04 15:00:45 +09:00
2025-12-04 15:00:45 +09:00
2025-12-04 15:00:45 +09:00
2025-12-04 15:23:43 +09:00
2025-12-04 16:16:56 +09:00
2025-12-04 19:37:18 +09:00
2025-12-04 19:34:19 +09:00
2025-12-06 16:22:38 +09:00
2025-12-04 19:38:06 +09:00
2025-12-04 19:37:18 +09:00
2025-12-05 23:26:55 +09:00
2025-12-05 23:26:55 +09:00
2025-12-07 23:09:25 +09:00
2025-12-07 01:45:03 +09:00
2025-12-07 01:45:03 +09:00
2025-12-04 16:16:56 +09:00
2025-12-07 14:17:58 +09:00
2025-12-07 23:09:25 +09:00
2025-12-07 23:09:25 +09:00
2025-12-07 23:09:25 +09:00
2025-12-07 23:09:25 +09:00
2025-12-07 21:29:19 +09:00
2025-12-07 01:45:03 +09:00
2025-12-04 16:55:11 +09:00
2025-12-07 01:45:03 +09:00
2025-12-04 17:03:14 +09:00
2025-12-07 01:45:03 +09:00
2025-12-07 01:45:03 +09:00
2025-12-07 01:45:03 +09:00
2025-12-08 02:41:53 +09:00
2025-12-04 16:35:34 +09:00
2025-12-04 16:55:11 +09:00
2025-12-08 03:06:20 +09:00
2025-12-04 17:47:19 +09:00
2025-12-04 17:47:19 +09:00
2025-12-04 17:47:19 +09:00
2025-12-04 17:47:19 +09:00
2025-12-04 18:20:07 +09:00
2025-12-04 18:20:07 +09:00
2025-12-04 18:20:07 +09:00
2025-12-04 17:47:19 +09:00
2025-12-08 10:13:34 +09:00
2025-12-08 10:13:34 +09:00
2025-12-08 10:13:34 +09:00
2025-12-04 19:34:19 +09:00
2025-12-08 13:08:44 +09:00
2025-12-08 13:08:44 +09:00
2025-12-08 15:17:53 +09:00
2025-12-08 15:17:53 +09:00
2025-12-08 15:17:53 +09:00
2025-12-08 15:17:53 +09:00
2025-12-08 16:34:04 +09:00
2025-12-08 16:34:04 +09:00
2025-12-08 18:36:13 +09:00
2025-12-08 19:29:10 +09:00
2025-12-08 21:09:00 +09:00
2025-12-08 21:19:54 +09:00
2025-12-08 21:26:57 +09:00
2025-12-08 21:42:51 +09:00
2025-12-08 21:34:16 +09:00
2025-12-08 23:14:10 +09:00
2025-12-08 21:26:57 +09:00
2025-12-08 23:59:19 +09:00
2025-12-09 00:59:38 +09:00
2025-12-09 00:59:38 +09:00
2025-12-09 00:59:38 +09:00
2025-12-09 01:09:54 +09:00
2025-12-09 01:47:07 +09:00
2025-12-05 16:05:32 +09:00
2025-12-09 03:07:15 +09:00
2025-12-09 03:40:25 +09:00
2025-12-06 03:30:03 +09:00
2025-12-09 04:20:28 +09:00
2025-12-06 11:09:52 +09:00
2025-12-06 11:09:03 +09:00
2025-12-09 06:04:09 +09:00
2025-12-06 16:22:38 +09:00
2025-12-09 14:45:04 +09:00
2025-12-09 14:45:04 +09:00
2025-12-09 13:28:15 +09:00
2025-12-09 13:58:31 +09:00
2025-12-06 14:46:33 +09:00
2025-12-09 14:45:04 +09:00
2025-12-09 14:56:05 +09:00
2025-12-06 14:46:33 +09:00
2025-12-09 15:28:49 +09:00
2025-12-09 16:19:08 +09:00
2025-12-09 18:32:03 +09:00
2025-12-09 18:32:03 +09:00
2025-12-09 18:56:51 +09:00
2025-12-09 19:14:01 +09:00
2025-12-09 19:39:01 +09:00
2025-12-09 19:57:32 +09:00
2025-12-09 23:35:57 +09:00
2025-12-07 21:02:20 +09:00
2025-12-07 21:02:20 +09:00
2025-12-05 16:06:39 +09:00
2025-12-06 11:10:38 +09:00
2025-11-23 05:53:27 +09:00
2025-12-07 21:02:20 +09:00
2025-12-04 03:58:02 +09:00
2025-12-04 12:40:01 +09:00
2025-11-21 07:00:05 +09:00
2025-11-21 08:03:03 +09:00
2025-11-21 08:03:03 +09:00
2025-12-08 15:17:53 +09:00
2025-11-20 17:10:03 +09:00
2025-11-20 17:10:03 +09:00
2025-11-20 17:10:03 +09:00