@@ -463,44 +463,40 @@ struct
463463 let ge ik x y = le ik y x
464464
465465 let lognot ik x = norm ik @@ match x with
466- | `Excluded (s , r ) ->
466+ | `Excluded (s , (( min , max ) as r ) ) ->
467467 let s' = S. map Z. lognot s in
468- let r' = match R. minimal r, R. maximal r with (* TODO: remove match *)
469- | min , max when Int. compare (- max) 0 < = 0 && Int. compare (- min) 0 > 0 ->
468+ let r' =
469+ if Int. compare (- max) 0 < = 0 && Int. compare (- min) 0 > 0 then
470470 (- max, - min)
471- | _ , _ -> apply_range Z. lognot r
471+ else
472+ apply_range Z. lognot r
472473 in
473474 `Excluded (s', r')
474475 | `Definite x -> `Definite (Z. lognot x)
475476 | `Bot -> `Bot
476477
477478 let logand ik x y = norm ik (match x,y with
478- | `Excluded (_, r ), `Definite i
479- | `Definite i , `Excluded (_ , r ) ->
479+ | `Excluded (_, (r1, r2) ), `Definite i
480+ | `Definite i , `Excluded (_ , ( r1 , r2 ) ) ->
480481 if Z. equal i Z. zero then
481482 `Definite Z. zero
482483 else if Z. equal i Z. one then
483484 of_interval IBool (Z. zero, Z. one)
484485 else (
485- match R. minimal r, R. maximal r with (* TODO: remove match *)
486- | r1 , r2 ->
487- match Z. compare i Z. zero > = 0 , Int. compare r1 0 > = 0 with
488- | true , true -> `Excluded (S. empty () , (0 , Int. min r2 (Z. numbits i)))
489- | true , _ -> `Excluded (S. empty () , (0 , Z. numbits i))
490- | _ , true -> `Excluded (S. empty () , (0 , r2))
491- | _ , _ ->
492- let b = Int. max (Z. numbits i) (Int. max (Int. abs r1) (Int. abs r2)) in
493- `Excluded (S. empty () , (- b, b))
486+ match Z. compare i Z. zero > = 0 , Int. compare r1 0 > = 0 with
487+ | true , true -> `Excluded (S. empty () , (0 , Int. min r2 (Z. numbits i)))
488+ | true , _ -> `Excluded (S. empty () , (0 , Z. numbits i))
489+ | _ , true -> `Excluded (S. empty () , (0 , r2))
490+ | _ , _ ->
491+ let b = Int. max (Z. numbits i) (Int. max (Int. abs r1) (Int. abs r2)) in
492+ `Excluded (S. empty () , (- b, b))
494493 )
495- | `Excluded (_ , p ), `Excluded (_ , r ) ->
496- begin match R. minimal p, R. maximal p, R. minimal r, R. maximal r with (* TODO: remove match *)
497- | p1 , p2 , r1 , r2 ->
498- begin match Int. compare p1 0 > = 0 , Int. compare r1 0 > = 0 with
499- | true , true -> `Excluded (S. empty () , (0 , Int. min p2 r2))
500- | true , _ -> `Excluded (S. empty () , (0 , p2))
501- | _ , true -> `Excluded (S. empty () , (0 , r2))
502- | _ , _ -> `Excluded (S. empty () , R. join p r)
503- end
494+ | `Excluded (_ , ((p1 , p2 ) as p )), `Excluded (_ , ((r1 , r2 ) as r )) ->
495+ begin match Int. compare p1 0 > = 0 , Int. compare r1 0 > = 0 with
496+ | true , true -> `Excluded (S. empty () , (0 , Int. min p2 r2))
497+ | true , _ -> `Excluded (S. empty () , (0 , p2))
498+ | _ , true -> `Excluded (S. empty () , (0 , r2))
499+ | _ , _ -> `Excluded (S. empty () , R. join p r)
504500 end
505501 (* The good case: *)
506502 | `Definite x , `Definite y ->
@@ -511,15 +507,13 @@ struct
511507 raise (ArithmeticOnIntegerBot (Printf. sprintf " %s op %s" (show x) (show y))))
512508
513509 let logor ik x y = norm ik (match x,y with
514- | `Excluded (_, r ), `Definite i
515- | `Definite i , `Excluded (_ , r ) ->
510+ | `Excluded (_, ((r1, r2) as r) ), `Definite i
511+ | `Definite i , `Excluded (_ , (( r1 , r2 ) as r ) ) ->
516512 if Z. compare i Z. zero > = 0 then
517513 `Excluded (S. empty () , R. join r (0 , Z. numbits i))
518514 else (
519- match R. minimal r, R. maximal r with (* TODO: remove match *)
520- | r1 , r2 ->
521- let b = Int. max (Z. numbits i) (Int. max (Int. abs r1) (Int. abs r2)) in
522- `Excluded (S. empty () , (- b, b))
515+ let b = Int. max (Z. numbits i) (Int. max (Int. abs r1) (Int. abs r2)) in
516+ `Excluded (S. empty () , (- b, b))
523517 )
524518 | `Excluded (_ , r1 ), `Excluded (_ , r2 ) -> `Excluded (S. empty () , R. join r1 r2)
525519 | `Definite x , `Definite y ->
@@ -530,26 +524,20 @@ struct
530524 raise (ArithmeticOnIntegerBot (Printf. sprintf " %s op %s" (show x) (show y))))
531525
532526 let logxor ik x y = norm ik (match x,y with
533- | `Definite i, `Excluded (_, r)
534- | `Excluded (_ , r ), `Definite i ->
535- begin match R. minimal r, R. maximal r with (* TODO: remove match *)
536- | r1 , r2 ->
537- let b = Int. max (Z. numbits i) (Int. max (Int. abs r1) (Int. abs r2)) in
538- if Int. compare r1 0 > = 0 && Z. compare i Z. zero > = 0 then
539- `Excluded (S. empty () , (0 , b))
540- else
541- `Excluded (S. empty () , (- b, b))
542- end
543- | `Excluded (_ , p ), `Excluded (_ , r ) ->
544- begin match R. minimal p, R. maximal p, R. minimal r, R. maximal r with (* TODO: remove match *)
545- | p1 , p2 , r1 , r2 ->
546- if Int. compare p1 0 > = 0 && Int. compare r1 0 > = 0 then
547- `Excluded (S. empty () , (0 , Int. max p2 r2))
548- else (
549- let b = List. fold_left Int. max 0 (List. map Int. abs [p1; p2; r1; r2]) in
550- `Excluded (S. empty () , (- b, b))
551- )
552- end
527+ | `Definite i, `Excluded (_, (r1, r2))
528+ | `Excluded (_ , (r1 , r2 )), `Definite i ->
529+ let b = Int. max (Z. numbits i) (Int. max (Int. abs r1) (Int. abs r2)) in
530+ if Int. compare r1 0 > = 0 && Z. compare i Z. zero > = 0 then
531+ `Excluded (S. empty () , (0 , b))
532+ else
533+ `Excluded (S. empty () , (- b, b))
534+ | `Excluded (_ , (p1 , p2 )), `Excluded (_ , (r1 , r2 )) ->
535+ if Int. compare p1 0 > = 0 && Int. compare r1 0 > = 0 then
536+ `Excluded (S. empty () , (0 , Int. max p2 r2))
537+ else (
538+ let b = List. fold_left Int. max 0 (List. map Int. abs [p1; p2; r1; r2]) in
539+ `Excluded (S. empty () , (- b, b))
540+ )
553541 (* The good case: *)
554542 | `Definite x , `Definite y ->
555543 (try `Definite (Z. logxor x y) with | Division_by_zero -> top_of ik)
0 commit comments