Propogate a constant through an impure c$::binop.
If the lvalue cannot be resolved, the environment is nullified, as we cannot be sure what has been mutated. For instance, consider the following sequence of statements:
int a = 1; int b = 4; *x = 0; int c = a + b;
Without knowing the value of
Function:
(defun const-prop-eval-impure-binop-expr (binop left right env) (declare (xargs :guard (and (binopp binop) (exprp left) (c::valuep right) (envp env)))) (declare (xargs :guard (not (pure-binopp binop)))) (let ((__function__ 'const-prop-eval-impure-binop-expr)) (declare (ignorable __function__)) (b* ((env (env-fix env)) (right (c::value-fix right))) (binop-case binop :asg (b* ((ident? (expr-to-ident left))) (if ident? (mv right (write-env ident? right env)) (mv nil nil))) :otherwise (mv nil nil)))))
Theorem:
(defthm value-optionp-of-const-prop-eval-impure-binop-expr.value? (b* (((mv ?value? ?env) (const-prop-eval-impure-binop-expr binop left right env))) (c::value-optionp value?)) :rule-classes :rewrite)
Theorem:
(defthm envp-of-const-prop-eval-impure-binop-expr.env (b* (((mv ?value? ?env) (const-prop-eval-impure-binop-expr binop left right env))) (envp env)) :rule-classes :rewrite)