Section DEFAULT.
Variable ge: genv.
Variable sp: block.
Variables m1 m2: mem.
Hypothesis PERM: forall b ofs k p, Mem.perm m1 b ofs k p -> Mem.perm m2 b ofs k p.
Let valid_pointer_inj:
forall b1 ofs b2 delta,
inject_id b1 = Some(b2, delta) ->
Mem.valid_pointer m1 b1 (Ptrofs.unsigned ofs) = true ->
Mem.valid_pointer m2 b2 (Ptrofs.unsigned (Ptrofs.add ofs (Ptrofs.repr delta))) = true.
Let weak_valid_pointer_inj:
forall b1 ofs b2 delta,
inject_id b1 = Some(b2, delta) ->
Mem.weak_valid_pointer m1 b1 (Ptrofs.unsigned ofs) = true ->
Mem.weak_valid_pointer m2 b2 (Ptrofs.unsigned (Ptrofs.add ofs (Ptrofs.repr delta))) = true.
Let weak_valid_pointer_no_overflow:
forall b1 ofs b2 delta,
inject_id b1 = Some(b2, delta) ->
Mem.weak_valid_pointer m1 b1 (Ptrofs.unsigned ofs) = true ->
0 <= Ptrofs.unsigned ofs + Ptrofs.unsigned (Ptrofs.repr delta) <= Ptrofs.max_unsigned.
Let valid_different_pointers_inj:
forall b1 ofs1 b2 ofs2 b1' delta1 b2' delta2,
b1 <> b2 ->
Mem.valid_pointer m1 b1 (Ptrofs.unsigned ofs1) = true ->
Mem.valid_pointer m1 b2 (Ptrofs.unsigned ofs2) = true ->
inject_id b1 = Some (b1', delta1) ->
inject_id b2 = Some (b2', delta2) ->
b1' <> b2' \/
Ptrofs.unsigned (Ptrofs.add ofs1 (Ptrofs.repr delta1)) <> Ptrofs.unsigned (Ptrofs.add ofs2 (Ptrofs.repr delta2)).
End DEFAULT.
(** ** Detecting operations that are redundant and can be turned into a move *)
Definition andimm_redundant (x: nval) (n: int) :=
match x with
| Nothing => true
| I m => Int.eq_dec (Int.and m (Int.not n)) Int.zero
| _ => false
end.
Definition orimm_redundant (x: nval) (n: int) :=
match x with
| Nothing => true
| I m => Int.eq_dec (Int.and m n) Int.zero
| _ => false
end.
Definition rolm_redundant (x: nval) (amount mask: int) :=
Int.eq_dec amount Int.zero && andimm_redundant x mask.
Definition zero_ext_redundant (n: Z) (x: nval) :=
match x with
| Nothing => true
| I m => Int.eq_dec (Int.zero_ext n m) m
| _ => false
end.
Definition sign_ext_redundant (n: Z) (x: nval) :=
match x with
| Nothing => true
| I m => Int.eq_dec (Int.zero_ext n m) m
| _ => false
end.

Lemma sign_ext_redundant_sound:
forall v w x n,
sign_ext_redundant n x = true ->
vagree v w (sign_ext n x) ->
0 < n ->
vagree (Val.sign_ext n v) w x.