diff --git a/dag_in_context/src/greedy_dag_extractor.rs b/dag_in_context/src/greedy_dag_extractor.rs index 0d5d9035..afe9c93c 100644 --- a/dag_in_context/src/greedy_dag_extractor.rs +++ b/dag_in_context/src/greedy_dag_extractor.rs @@ -582,6 +582,19 @@ impl<'a> Extractor<'a> { let mut shared_total = NotNan::new(0.).unwrap(); let mut unshared_total = info.cm.get_op_cost(&node.op); + + // special case: when the call is recursive, set super high cost + if node.op == "Call" { + let func_name = &node.children[0]; + let func_name_str = &info.egraph[func_name].op; + assert!(func_name_str.starts_with('\"') && func_name_str.ends_with('\"')); + let func_name_str_without_quotes = &func_name_str[1..func_name_str.len() - 1]; + if func_name_str_without_quotes == info._func { + eprintln!("here"); + unshared_total = NotNan::new(100000000000.0).unwrap(); + } + } + let mut costs: HashTrieMap = Default::default(); let index_of_biggest_child = child_cost_sets .iter() diff --git a/dag_in_context/src/optimizations/rec_to_loop.egg b/dag_in_context/src/optimizations/rec_to_loop.egg index 2a774d38..6f9fa2bc 100644 --- a/dag_in_context/src/optimizations/rec_to_loop.egg +++ b/dag_in_context/src/optimizations/rec_to_loop.egg @@ -86,7 +86,8 @@ (= always-runs-len (tuple-length always-runs)) (= start-ty (TupleT start-ty-list)) (HasType body func-ty)) - ((let loop-ty + ((panic "good") + (let loop-ty (TupleT (TLConcat start-ty-list (TCons (IntT) (TNil))))) ;; recursive case in the loop (let new-rec-case