فهرست منبع

Evaluate constant unaries in the CFG optimizer

jonathanvdc 8 سال پیش
والد
کامیت
175d8ab3b8
1فایلهای تغییر یافته به همراه6 افزوده شده و 0 حذف شده
  1. 6 0
      kernel/modelverse_jit/cfg_optimization.py

+ 6 - 0
kernel/modelverse_jit/cfg_optimization.py

@@ -316,6 +316,12 @@ def simplify_values(entry_point):
                     definition.redefine(
                         cfg_ir.Literal(
                             eval('%r %s %r' % (lhs.literal, def_val.operator, rhs.literal))))
+            elif isinstance(def_val, cfg_ir.Unary):
+                operand = cfg_ir.get_def_value(def_val.operand)
+                if isinstance(operand, cfg_ir.Literal):
+                    definition.redefine(
+                        cfg_ir.Literal(
+                            eval('%s %r' % (def_val.operator, operand.literal))))
 
 def inline_constants(entry_point):
     """Replaces reads of constant nodes by the literals they contain."""