feat(joinir): Phase 170-C-2b LoopUpdateSummary wiring into shape detection

Wire LoopUpdateSummary box into real code paths:

- Add `update_summary: Option<LoopUpdateSummary>` field to LoopFeatures
- Add `detect_with_updates()` method to CaseALoweringShape
  - Uses UpdateKind (CounterLike/AccumulationLike) for classification
  - Single CounterLike carrier → StringExamination
  - AccumulationLike present → ArrayAccumulation or IterationWithAccumulation
- Update loop_to_join.rs to use detect_with_updates()
- Update deprecated detect() to use detect_with_updates() internally
- Set update_summary: None in AST-based feature extraction

Carrier name heuristics now encapsulated in LoopUpdateSummary box.
No regression: 15/16 loop smoke tests pass (1 failure is pre-existing).

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-07 14:33:54 +09:00
parent c9458ef11e
commit 4170500c51
4 changed files with 98 additions and 10 deletions

View File

@ -136,6 +136,13 @@ pub struct LoopFeatures {
/// Number of continue targets
pub continue_count: usize,
/// Phase 170-C-2b: Carrier update pattern summary
///
/// Contains UpdateKind (CounterLike/AccumulationLike/Other) for each carrier.
/// Used by CaseALoweringShape for more precise shape detection.
/// None if carrier names are not available.
pub update_summary: Option<crate::mir::join_ir::lowering::loop_update_summary::LoopUpdateSummary>,
}
impl LoopFeatures {
@ -208,6 +215,13 @@ pub fn extract_features(loop_form: &LoopForm, scope: Option<&LoopScopeShape>) ->
// For now, we infer it from carrier_count > 1 (Pattern 3 heuristic)
let has_if = has_if_else_phi;
// Phase 170-C-2b: Build update_summary from carrier names
// Note: carriers is BTreeSet<String>, so each item is already a String
let update_summary = scope.map(|s| {
let carrier_names: Vec<String> = s.carriers.iter().cloned().collect();
crate::mir::join_ir::lowering::loop_update_summary::analyze_loop_updates(&carrier_names)
});
LoopFeatures {
has_break,
has_continue,
@ -216,6 +230,7 @@ pub fn extract_features(loop_form: &LoopForm, scope: Option<&LoopScopeShape>) ->
carrier_count,
break_count,
continue_count,
update_summary,
}
}