summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/constant_fold.ml7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/constant_fold.ml b/src/constant_fold.ml
index 7e21294b..7a7067ef 100644
--- a/src/constant_fold.ml
+++ b/src/constant_fold.ml
@@ -221,7 +221,12 @@ let rw_exp target ok not_ok istate =
| E_app (id, args) when List.for_all is_constant args ->
let env = env_of_annot annot in
- if not (Env.is_extern id env target) then
+ (* We want to fold all primitive operations, but avoid folding
+ non-primitives that are defined in target-specific way. *)
+ let is_primop =
+ Env.is_extern id env "interpreter" && StringMap.mem (Env.get_extern id env "interpreter") safe_primops
+ in
+ if not (Env.is_extern id env target) || is_primop then
evaluate e_aux annot
else
E_aux (e_aux, annot)