Skip to content

Commit f134311

Browse files
committed
Safety checker: minimal support for flag combinations
(cherry picked from commit fc2ff76)
1 parent eaf0d18 commit f134311

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

compiler/safety/success/flags.jazz

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export fn f(reg u64 x) -> reg u64 {
2+
reg u64 r;
3+
reg bool c;
4+
r = x;
5+
?{ "==" = c }, x = #SUB(x, 1);
6+
r = x if !c;
7+
return r;
8+
}

compiler/safetylib/safetyAbsExpr.ml

+13
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,19 @@ module AbsExpr (AbsDom : AbsNumBoolType) = struct
765765
| Some (ty,eb,el,er) -> aux (Pif (ty,eb,el,er))
766766
| None -> flat_bexpr_to_btcons abs op2 e1 e2 end
767767

768+
| PappN (Ocombine_flags c, [ eof; ecf; esf; ezf ]) ->
769+
begin match c with
770+
| E.CF_EQ -> aux ezf
771+
| E.CF_LT Unsigned -> aux ecf
772+
| E.CF_LE Unsigned -> BOr (aux ecf, aux ezf)
773+
| E.CF_NEQ -> aux (Papp1 (Onot, ezf))
774+
| E.CF_LT Signed -> aux (Papp1 (Onot, (Papp2 (E.Obeq, eof, esf))))
775+
| E.CF_LE Signed -> BOr (aux (Papp1 (Onot, (Papp2 (E.Obeq, eof, esf)))), aux ezf)
776+
| E.CF_GE Signed -> aux (Papp2 (E.Obeq, eof, esf))
777+
| E.CF_GE Unsigned -> aux (Papp1 (Onot, ecf))
778+
| E.CF_GT Unsigned -> BAnd (aux (Papp1 (Onot, ecf)), aux (Papp1 (Onot, ezf)))
779+
| E.CF_GT Signed -> BAnd (aux (Papp2 (E.Obeq, eof, esf)), aux (Papp1 (Onot, ezf)))
780+
end
768781
| _ -> assert false
769782

770783
and flat_bexpr_to_btcons abs op2 e1 e2 =

0 commit comments

Comments
 (0)