diff --git a/lfs.c b/lfs.c index 955af912..1b54dc3e 100644 --- a/lfs.c +++ b/lfs.c @@ -2866,7 +2866,6 @@ again:; // make jump absolute jump = branch - jump; lfs_size_t branch_ = branch + d; - bool diverged_this_alt = false; // do bounds want to take different paths? begin diverging if (!lfsr_d_isdiverged(d_state) @@ -2898,7 +2897,7 @@ again:; weight); // stitch together diverged branches - if (d_state == LFSR_D_DIVERGEDUPPER && d_tag) { + if (d_state == LFSR_D_DIVERGEDUPPER) { printf("%04x->%04x: stitching: 0x%x w%d, 0x%x\n", branch, rbyd->eoff, @@ -2915,8 +2914,72 @@ again:; } } - diverged_this_alt = true; + if (lfsr_tag_follow2( + alt, weight, + p_alts[0], p_weights[0], + lower_rid, upper_rid, + a_rid, a_tag)) { + lfsr_tag_flip2( + &alt, &weight, + p_alts[0], p_weights[0], + lower_rid, upper_rid); + lfs_swap32(&jump, &branch_); + } + lfsr_tag_trim( + alt, weight, + &lower_rid, &upper_rid, + &lower_tag, &upper_tag); + + printf("%04x->%04x: dprune 0x%x w%d\n", + branch, + rbyd->eoff, + alt, + weight); + // TODO need this? + // propagate pruning to yellow splits to avoid issues + // with tail-recursive recoloring +// if (lfsr_d_isdiverged(d_state)) { +// d_pruned = true; +// } + // TODO can we move y_branch updates to beginning of loop? + y_branch = branch; + branch = branch_; + continue; } + + // don't write diverging lower alts + } else if (d_state == LFSR_D_DIVERGINGLOWER) { + if (lfsr_tag_follow2( + alt, weight, + p_alts[0], p_weights[0], + lower_rid, upper_rid, + a_rid, a_tag)) { + lfsr_tag_flip2( + &alt, &weight, + p_alts[0], p_weights[0], + lower_rid, upper_rid); + lfs_swap32(&jump, &branch_); + } + lfsr_tag_trim( + alt, weight, + &lower_rid, &upper_rid, + &lower_tag, &upper_tag); + + printf("%04x->%04x: dprune 0x%x w%d\n", + branch, + rbyd->eoff, + alt, + weight); + // TODO need this? + // propagate pruning to yellow splits to avoid issues + // with tail-recursive recoloring +// if (lfsr_d_isdiverged(d_state)) { +// d_pruned = true; +// } + // TODO can we move y_branch updates to beginning of loop? + y_branch = branch; + branch = branch_; + continue; } // if (lfsr_d_isdiverged(d_state)) { @@ -2939,7 +3002,9 @@ again:; lower_rid, upper_rid, lower_tag, upper_tag) // prune because of diverged paths? - || d_state == LFSR_D_DIVERGINGLOWER +// || d_state == LFSR_D_DIVERGINGLOWER + // TODO can we adjust lower/upper rid/tag to make this + // happen implicitly? || (lfsr_d_isdiverged(d_state) && (d_state == LFSR_D_DIVERGEDUPPER) ^ lfsr_tag_isgt(alt) @@ -2981,21 +3046,21 @@ again:; // black alts just become unreachable, if we pruned these // it would break the coloring of our tree } else { - if (d_state == LFSR_D_DIVERGINGLOWER || diverged_this_alt) { - printf("%04x->%04x: dprune 0x%x w%d\n", - branch, - rbyd->eoff, - alt, - weight); - // propagate pruning to yellow splits to avoid issues - // with tail-recursive recoloring - if (lfsr_d_isdiverged(d_state)) { - d_pruned = true; - } - y_branch = branch; - branch = branch_; - continue; - } else { +// if (d_state == LFSR_D_DIVERGINGLOWER) { +// printf("%04x->%04x: dprune 0x%x w%d\n", +// branch, +// rbyd->eoff, +// alt, +// weight); +// // propagate pruning to yellow splits to avoid issues +// // with tail-recursive recoloring +// if (lfsr_d_isdiverged(d_state)) { +// d_pruned = true; +// } +// y_branch = branch; +// branch = branch_; +// continue; +// } else { printf("%04x->%04x: bprune 0x%x w%d\n", branch, rbyd->eoff, @@ -3004,7 +3069,7 @@ again:; alt = LFSR_TAG_ALT(LFSR_TAG_LE, LFSR_TAG_B, 0); weight = 0; // jump = 0; - } +// } } }