Files
hakorune/docs/development/current
nyash-codex fa8727c2f8 docs: Phase 196 Select expansion bug fix instruction document
Phase 196 investigation & fix plan for JoinIR→MIR Select conversion bug:
- Goal: Fix "correct PHI in JoinIR → undefined PHI inputs in MIR" issue
- Scope: Bridge layer only (join_ir_vm_bridge / merge line)

Task breakdown:
- 196-1: Minimal reproduction case (phase195_sum_count.hako)
  - Record expected JoinIR structure (ValueIds, block IDs)
  - Record broken MIR structure (undefined PHI inputs)
  - Identify which Select instruction causes the bug
- 196-2: Select expansion path analysis (read-only)
  - Locate handle_select in joinir_block.rs
  - Understand "1 Select = 3 blocks + 1 PHI" conversion
  - Document responsibility locations
- 196-3: Fix strategy (no new boxes)
  - Candidate 1: PHI inputs ValueId check (use emit results)
  - Candidate 2: Block reuse vs overwrite (Phase 33-20 lesson)
  - Candidate 3: JoinInlineBoundary remapper usage (remap before PHI)
  - One-at-a-time fix approach
- 196-4: E2E re-verification + regression check
  - phase195_sum_count.hako → 72
  - loop_if_phi.hako (single-carrier P3)
  - P1/P2/P4 representative tests
- 196-5: Documentation updates
  - phase196-select-bug-analysis.md (Before/After)
  - CURRENT_TASK.md (Phase 196 completion)
  - overview (Select expansion line verified)

Design principles:
- Minimal changes (existing Select expansion logic only)
- Focus on one candidate at a time (Fail-Fast)
- Explicit errors (remapper.get_value() must not silently fail)
- Document-driven (record Before/After for future reference)

Success criteria:
- phase195_sum_count.hako outputs 72
- No SSA-undef / PHI errors
- No regressions in P1/P2/P3/P4 tests

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-09 14:07:42 +09:00
..