Skip to content

Conversation

@dvdvgt
Copy link
Collaborator

@dvdvgt dvdvgt commented Dec 1, 2025

Closes #1229

@dvdvgt
Copy link
Collaborator Author

dvdvgt commented Dec 1, 2025

Before

function motz_0(n_23, ks_1706, k_937) {
  motz_1: while (true) {
    if ((n_23 <= (1))) {
      return () => k_937(1, ks_1706);
    } else {
      function product_2(i_45, ks_1707, k_938) {
        return motz_0(i_45, ks_1707, (v_r_846, ks_1708) =>
          motz_0((((n_23 - (2))) - i_45), ks_1708, (v_r_847, ks_1709) =>
            () => k_938((v_r_846 * v_r_847), ks_1709)));
      }
      /* prepare call */
      const tmp_n_1 = n_23;
      const tmp_k_6 = k_937;
      k_937 = (v_r_848, ks_1710) =>
        sum_4(0, (tmp_n_1 - (2)), product_2, ks_1710, (v_r_849, ks_1711) =>
          () => tmp_k_6((v_r_848 + v_r_849), ks_1711));
      n_23 = (tmp_n_1 - (1));
      continue motz_1;
    }
  }
}

After

function motz_0(n_23, ks_1706, k_937) {
  motz_1: while (true) {
    if ((n_23 <= (1))) {
      return () => k_937(1, ks_1706);
    } else {
      function product_2(i_45, ks_1707, k_938) {
        return motz_0(i_45, ks_1707, (v_r_846, ks_1708) =>
          motz_0((((n_23 - (2))) - i_45), ks_1708, (v_r_847, ks_1709) =>
            () => k_938((v_r_846 * v_r_847), ks_1709)));
      }
      /* prepare call */
      const tmp_n_1 = n_23;
      const tmp_k_6 = k_937;
      function product_subst_0(i_45, ks_1707, k_938) {
        return motz_0(i_45, ks_1707, (v_r_846, ks_1708) =>
          motz_0((((tmp_n_1 - (2))) - i_45), ks_1708, (v_r_847, ks_1709) =>
            () => k_938((v_r_846 * v_r_847), ks_1709)));
      }
      k_937 = (v_r_848, ks_1710) =>
        sum_4(0, (tmp_n_1 - (2)), product_subst_0, ks_1710, (v_r_849, ks_1711) =>
          () => tmp_k_6((v_r_848 + v_r_849), ks_1711));
      n_23 = (tmp_n_1 - (1));
      continue motz_1;
    }
  }
}

Disadvantage: More dead-code

@jiribenes
Copy link
Contributor

Could we add this benchmark as one of those tests that also run with noopt (say, on JS) so that we catch it next time?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TranformerCPS mutable variable capture bug

3 participants