Skip to content

Commit

Permalink
Compiler: get rid of useless Cond
Browse files Browse the repository at this point in the history
  • Loading branch information
hhugo committed Dec 14, 2022
1 parent 7deb7d8 commit 9eb04f2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions compiler/lib/eval.ml
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,13 @@ let the_cond_of info x =

let eval_branch info = function
| Cond (x, ftrue, ffalse) as b -> (
match the_cond_of info x with
| Zero -> Branch ffalse
| Non_zero -> Branch ftrue
| Unknown -> b)
if Poly.(ftrue = ffalse)
then Branch ftrue
else
match the_cond_of info x with
| Zero -> Branch ffalse
| Non_zero -> Branch ftrue
| Unknown -> b)
| Switch (x, const, tags) as b -> (
(* [the_case_of info (Pv x)] might be meaningless when we're inside a dead code.
The proper fix would be to remove the deadcode entirely.
Expand Down

0 comments on commit 9eb04f2

Please sign in to comment.