@@ -305,9 +305,7 @@ struct
305305 * If the upper bound of a is divisible by b, we can also meet with the result of a/b*b - c to get the precise [3,3].
306306 * If b is negative we have to look at the lower bound. *)
307307 let is_divisible bound =
308- match bound a with
309- | Some ba -> ID. rem (ID. of_int ikind ba) b |> ID. to_int = Some Z. zero
310- | None -> false
308+ GobOption. exists (fun ba -> ID. rem (ID. of_int ikind ba) b |> ID. to_int = Some Z. zero) (bound a)
311309 in
312310 let max_pos = match ID. maximal b with None -> true | Some x -> Z. compare x Z. zero > = 0 in
313311 let min_neg = match ID. minimal b with None -> true | Some x -> Z. compare x Z. zero < 0 in
@@ -735,6 +733,7 @@ struct
735733 | _ -> Int c
736734 in
737735 (* handle special calls *)
736+ let default () = update_lval c x c' ID. pretty in
738737 begin match x, t with
739738 | (Var v , offs ), TInt (ik , _ ) ->
740739 let tmpSpecial = man.ask (Queries. TmpSpecial (v, Offset.Exp. of_cil offs)) in
@@ -744,24 +743,21 @@ struct
744743 let c' = ID. cast_to ik c in (* different ik! *)
745744 inv_exp (Int (ID. join c' (ID. neg c'))) xInt st
746745 | tmpSpecial ->
747- begin match ID. to_bool c with
748- | Some tv ->
749- begin match tmpSpecial with
750- | `Lifted (Isfinite xFloat ) when tv -> inv_exp (Float (FD. finite (unroll_fk_of_exp xFloat))) xFloat st
751- | `Lifted (Isnan xFloat ) when tv -> inv_exp (Float (FD. nan_of (unroll_fk_of_exp xFloat))) xFloat st
752- (* should be correct according to C99 standard*)
753- (* The following do to_bool and of_bool to convert Not{0} into 1 for downstream float inversions *)
754- | `Lifted (Isgreater (xFloat , yFloat )) -> inv_exp (Int (ID. of_bool ik tv)) (BinOp (Gt , xFloat, yFloat, (typeOf xFloat))) st
755- | `Lifted (Isgreaterequal (xFloat , yFloat )) -> inv_exp (Int (ID. of_bool ik tv)) (BinOp (Ge , xFloat, yFloat, (typeOf xFloat))) st
756- | `Lifted (Isless (xFloat , yFloat )) -> inv_exp (Int (ID. of_bool ik tv)) (BinOp (Lt , xFloat, yFloat, (typeOf xFloat))) st
757- | `Lifted (Islessequal (xFloat , yFloat )) -> inv_exp (Int (ID. of_bool ik tv)) (BinOp (Le , xFloat, yFloat, (typeOf xFloat))) st
758- | `Lifted (Islessgreater (xFloat , yFloat )) -> inv_exp (Int (ID. of_bool ik tv)) (BinOp (LOr , (BinOp (Lt , xFloat, yFloat, (typeOf xFloat))), (BinOp (Gt , xFloat, yFloat, (typeOf xFloat))), (TInt (IBool , [] )))) st
759- | _ -> update_lval c x c' ID. pretty
760- end
761- | None -> update_lval c x c' ID. pretty
762- end
746+ BatOption. map_default_delayed (fun tv ->
747+ match tmpSpecial with
748+ | `Lifted (Isfinite xFloat ) when tv -> inv_exp (Float (FD. finite (unroll_fk_of_exp xFloat))) xFloat st
749+ | `Lifted (Isnan xFloat ) when tv -> inv_exp (Float (FD. nan_of (unroll_fk_of_exp xFloat))) xFloat st
750+ (* should be correct according to C99 standard*)
751+ (* The following do to_bool and of_bool to convert Not{0} into 1 for downstream float inversions *)
752+ | `Lifted (Isgreater (xFloat , yFloat )) -> inv_exp (Int (ID. of_bool ik tv)) (BinOp (Gt , xFloat, yFloat, (typeOf xFloat))) st
753+ | `Lifted (Isgreaterequal (xFloat , yFloat )) -> inv_exp (Int (ID. of_bool ik tv)) (BinOp (Ge , xFloat, yFloat, (typeOf xFloat))) st
754+ | `Lifted (Isless (xFloat , yFloat )) -> inv_exp (Int (ID. of_bool ik tv)) (BinOp (Lt , xFloat, yFloat, (typeOf xFloat))) st
755+ | `Lifted (Islessequal (xFloat , yFloat )) -> inv_exp (Int (ID. of_bool ik tv)) (BinOp (Le , xFloat, yFloat, (typeOf xFloat))) st
756+ | `Lifted (Islessgreater (xFloat , yFloat )) -> inv_exp (Int (ID. of_bool ik tv)) (BinOp (LOr , (BinOp (Lt , xFloat, yFloat, (typeOf xFloat))), (BinOp (Gt , xFloat, yFloat, (typeOf xFloat))), (TInt (IBool , [] )))) st
757+ | _ -> default ()
758+ ) default (ID. to_bool c)
763759 end
764- | _ , _ -> update_lval c x c' ID. pretty
760+ | _ , _ -> default ()
765761 end
766762 | Float c ->
767763 let c' = match t with
0 commit comments