From 9eb04f229762fa1a3c691fe0cff6c457cc78068e Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Wed, 14 Dec 2022 19:29:30 +0100 Subject: [PATCH] Compiler: get rid of useless Cond --- compiler/lib/eval.ml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/compiler/lib/eval.ml b/compiler/lib/eval.ml index 813f626761..bdc5a81116 100644 --- a/compiler/lib/eval.ml +++ b/compiler/lib/eval.ml @@ -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.