(** Operations that are so cheap to recompute that CSE should not factor them out. *)
Definition is_trivial_op (op: operation) : bool :=
match op with
| Omove => true
| Ointconst n => Int.eq (Int.sign_ext 12 n) n
| Olongconst n => Int64.eq (Int64.sign_ext 12 n) n
| Oaddrstack _ => true
| _ => false
end.
(** Operations that depend on the memory state. *)
Definition op_depends_on_memory (op: operation) : bool :=
match op with
| Ocmp (Ccompu _) => negb Archi.ptr64
| Ocmp (Ccompuimm _ _) => negb Archi.ptr64
| Ocmp (Ccomplu _) => Archi.ptr64
| Ocmp (Ccompluimm _ _) => Archi.ptr64
| _ => false
end.

Lemma op_depends_on_memory_correct:
forall (F V: Type) (ge: Genv.t F V) sp op args m1 m2,
op_depends_on_memory op = false ->
eval_operation ge sp op args m1 = eval_operation ge sp op args m2.