Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optimization for if with both then and else branch the same #1106

Open
ordinarymath opened this issue Dec 8, 2024 · 0 comments
Open

Comments

@ordinarymath
Copy link
Contributor

Right now when cakeml is given the program of the form

fun const_optimization x =
  case x of
    A a => 10
  | B a b => 10
  | C a b c => 10;
  
fun const_optimization2 x =
  case x of
    A a => x
  | B a b => x
  | C a b c => x;

it results in code like this where the branches are still there

(func const_optimization@474 (0)
   (seq
      (2 := (TagLenEq 0 1) (0) none)
      (if 2
         (seq
            (5 := (Const 10) () none)
            (return 5))
         (seq
            (6 := (TagLenEq 0 2) (0) none)
            (if 6
               (seq
                  (11 := (Const 10) () none)
                  (return 11))
               (seq
                  (18 := (Const 10) () none)
                  (return 18)))))))

@myreen thinks that this optimization should be done in datalang

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

No branches or pull requests

2 participants