@@ -624,19 +624,32 @@ module BitfieldFunctor (Ints_t : IntOps.IntOps): Bitfield_SOverflow with type in
624624
625625 (* Invariant *)
626626
627- let invariant_ikind e ik (z ,o ) =
628- if z =: BArith. one_mask && o =: BArith. one_mask then
629- Invariant. top ()
630- else if BArith. is_invalid (z,o) then
631- Invariant. none
632- else
627+ let invariant_ikind e ik (z , o ) =
628+ if BArith. is_invalid (z, o) then
629+ Invariant. none (* TODO: should this ever even happen? *)
630+ else (
633631 let open GoblintCil.Cil in
634- let def0 = z &: (! : o ) in
635- let def1 = o &: (! : z ) in
636- let (def0, def1) = BatTuple.Tuple2. mapn (kintegerCilint ik) (Ints_t. to_bigint def0, Ints_t. to_bigint def1) in
637- let exp0 = Invariant. of_exp (BinOp (Eq , (BinOp (BAnd , (UnOp (BNot , e, TInt (ik,[] ))), def0, TInt (ik,[] ))), def0, intType)) in
638- let exp1 = Invariant. of_exp (BinOp (Eq , (BinOp (BAnd , e, def1, TInt (ik,[] ))), def1, intType)) in
639- Invariant. meet exp0 exp1
632+ let ik_type = TInt (ik, [] ) in
633+ let i1 =
634+ let def0 = z &: (! : o ) in
635+ if def0 =: BArith. zero_mask then
636+ Invariant. none
637+ else (
638+ let def0 = kintegerCilint ik (Ints_t. to_bigint def0) in
639+ Invariant. of_exp (BinOp (Eq , (BinOp (BAnd , UnOp (BNot , e, ik_type), def0, ik_type)), def0, intType))
640+ )
641+ in
642+ let i2 =
643+ let def1 = o &: (! : z ) in
644+ if def1 =: BArith. zero_mask then
645+ Invariant. none
646+ else (
647+ let def1 = kintegerCilint ik (Ints_t. to_bigint def1) in
648+ Invariant. of_exp (BinOp (Eq , (BinOp (BAnd , e, def1, ik_type)), def1, intType))
649+ )
650+ in
651+ Invariant. (i1 && i2)
652+ )
640653
641654 let starting ik n =
642655 let (min_ik, max_ik) = Size. range ik in
0 commit comments