Author: Maciej Fijalkowski <[email protected]>
Branch: optresult
Changeset: r74522:555089bcfdc6
Date: 2014-11-14 18:18 +0200
http://bitbucket.org/pypy/pypy/changeset/555089bcfdc6/
Log: more hacking
diff --git a/rpython/jit/metainterp/optimizeopt/intbounds.py
b/rpython/jit/metainterp/optimizeopt/intbounds.py
--- a/rpython/jit/metainterp/optimizeopt/intbounds.py
+++ b/rpython/jit/metainterp/optimizeopt/intbounds.py
@@ -73,9 +73,9 @@
v2 = self.getvalue(op.getarg(1))
if v1 is v2:
if op.getopnum() == rop.INT_OR:
- self.make_equal_to(op.result, v1)
+ self.make_equal_to(op, v1)
else:
- self.make_constant_int(op.result, 0)
+ self.make_constant_int(op, 0)
return
self.emit_operation(op)
if v1.intbound.known_ge(IntBound(0, 0)) and \
@@ -179,7 +179,7 @@
# b.has_lower
if b.has_lower and b.has_upper:
# Synthesize the reverse op for optimize_default to reuse
- self.pure(rop.INT_RSHIFT, [op.result, op.getarg(1)], op.getarg(0))
+ self.pure(rop.INT_RSHIFT, [op, op.getarg(1)], op.getarg(0))
def optimize_INT_RSHIFT(self, op):
v1 = self.getvalue(op.getarg(0))
@@ -187,7 +187,7 @@
b = v1.intbound.rshift_bound(v2.intbound)
if b.has_lower and b.has_upper and b.lower == b.upper:
# constant result (likely 0, for rshifts that kill all bits)
- self.make_constant_int(op.result, b.lower)
+ self.make_constant_int(op, b.lower)
else:
self.emit_operation(op)
r = self.getvalue(op)
@@ -251,7 +251,7 @@
v1 = self.getvalue(op.getarg(0))
v2 = self.getvalue(op.getarg(1))
if v1 is v2:
- self.make_constant_int(op.result, 0)
+ self.make_constant_int(op, 0)
return
resbound = v1.intbound.sub_bound(v2.intbound)
if resbound.bounded():
@@ -276,9 +276,9 @@
v1 = self.getvalue(op.getarg(0))
v2 = self.getvalue(op.getarg(1))
if v1.intbound.known_lt(v2.intbound):
- self.make_constant_int(op.result, 1)
+ self.make_constant_int(op, 1)
elif v1.intbound.known_ge(v2.intbound) or v1 is v2:
- self.make_constant_int(op.result, 0)
+ self.make_constant_int(op, 0)
else:
self.emit_operation(op)
@@ -286,9 +286,9 @@
v1 = self.getvalue(op.getarg(0))
v2 = self.getvalue(op.getarg(1))
if v1.intbound.known_gt(v2.intbound):
- self.make_constant_int(op.result, 1)
+ self.make_constant_int(op, 1)
elif v1.intbound.known_le(v2.intbound) or v1 is v2:
- self.make_constant_int(op.result, 0)
+ self.make_constant_int(op, 0)
else:
self.emit_operation(op)
@@ -296,9 +296,9 @@
v1 = self.getvalue(op.getarg(0))
v2 = self.getvalue(op.getarg(1))
if v1.intbound.known_le(v2.intbound) or v1 is v2:
- self.make_constant_int(op.result, 1)
+ self.make_constant_int(op, 1)
elif v1.intbound.known_gt(v2.intbound):
- self.make_constant_int(op.result, 0)
+ self.make_constant_int(op, 0)
else:
self.emit_operation(op)
@@ -306,9 +306,9 @@
v1 = self.getvalue(op.getarg(0))
v2 = self.getvalue(op.getarg(1))
if v1.intbound.known_ge(v2.intbound) or v1 is v2:
- self.make_constant_int(op.result, 1)
+ self.make_constant_int(op, 1)
elif v1.intbound.known_lt(v2.intbound):
- self.make_constant_int(op.result, 0)
+ self.make_constant_int(op, 0)
else:
self.emit_operation(op)
@@ -316,11 +316,11 @@
v1 = self.getvalue(op.getarg(0))
v2 = self.getvalue(op.getarg(1))
if v1.intbound.known_gt(v2.intbound):
- self.make_constant_int(op.result, 0)
+ self.make_constant_int(op, 0)
elif v1.intbound.known_lt(v2.intbound):
- self.make_constant_int(op.result, 0)
+ self.make_constant_int(op, 0)
elif v1 is v2:
- self.make_constant_int(op.result, 1)
+ self.make_constant_int(op, 1)
else:
self.emit_operation(op)
@@ -328,18 +328,18 @@
v1 = self.getvalue(op.getarg(0))
v2 = self.getvalue(op.getarg(1))
if v1.intbound.known_gt(v2.intbound):
- self.make_constant_int(op.result, 1)
+ self.make_constant_int(op, 1)
elif v1.intbound.known_lt(v2.intbound):
- self.make_constant_int(op.result, 1)
+ self.make_constant_int(op, 1)
elif v1 is v2:
- self.make_constant_int(op.result, 0)
+ self.make_constant_int(op, 0)
else:
self.emit_operation(op)
def optimize_INT_FORCE_GE_ZERO(self, op):
value = self.getvalue(op.getarg(0))
if value.intbound.known_ge(IntBound(0, 0)):
- self.make_equal_to(op.result, value)
+ self.make_equal_to(op, value)
else:
self.emit_operation(op)
diff --git a/rpython/jit/metainterp/optimizeopt/rewrite.py
b/rpython/jit/metainterp/optimizeopt/rewrite.py
--- a/rpython/jit/metainterp/optimizeopt/rewrite.py
+++ b/rpython/jit/metainterp/optimizeopt/rewrite.py
@@ -26,7 +26,8 @@
def propagate_forward(self, op):
if op.boolinverse != -1 or op.boolreflex != -1:
- args = self.optimizer.make_args_key(op)
+ args = self.optimizer.make_args_key(op.getopnum(),
+ op.getarglist(), op.getdescr())
if self.find_rewritable_bool(op, args):
return
@@ -35,7 +36,7 @@
def try_boolinvers(self, op, targs):
oldop = self.get_pure_result(targs)
if oldop is not None and oldop.getdescr() is op.getdescr():
- value = self.getvalue(oldop.result)
+ value = self.getvalue(oldop)
if value.is_constant():
if value.box.same_constant(CONST_1):
self.make_constant(op, CONST_0)
@@ -50,26 +51,26 @@
def find_rewritable_bool(self, op, args):
oldopnum = op.boolinverse
if oldopnum != -1:
- targs = self.optimizer.make_args_key(ResOperation(oldopnum,
[args[0], args[1]],
- None))
+ targs = self.optimizer.make_args_key(oldopnum, [args[0], args[1]],
+ None)
if self.try_boolinvers(op, targs):
return True
oldopnum = op.boolreflex # FIXME: add INT_ADD, INT_MUL
if oldopnum != -1:
- targs = self.optimizer.make_args_key(ResOperation(oldopnum,
[args[1], args[0]],
- None))
+ targs = self.optimizer.make_args_key(oldopnum, [args[1], args[0]],
+ None)
oldop = self.get_pure_result(targs)
if oldop is not None and oldop.getdescr() is op.getdescr():
- self.make_equal_to(op.result, self.getvalue(oldop.result))
+ self.make_equal_to(op, self.getvalue(oldop))
return True
if op.boolreflex == -1:
return False
oldopnum = opclasses[op.boolreflex].boolinverse
if oldopnum != -1:
- targs = self.optimizer.make_args_key(
- ResOperation(oldopnum, [args[1], args[0]], None))
+ targs = self.optimizer.make_args_key(oldopnum, [args[1], args[0]],
+ None)
if self.try_boolinvers(op, targs):
return True
@@ -100,9 +101,9 @@
v1 = self.getvalue(op.getarg(0))
v2 = self.getvalue(op.getarg(1))
if v1.is_null():
- self.make_equal_to(op.result, v2)
+ self.make_equal_to(op, v2)
elif v2.is_null():
- self.make_equal_to(op.result, v1)
+ self.make_equal_to(op, v1)
else:
self.emit_operation(op)
@@ -110,7 +111,7 @@
v1 = self.getvalue(op.getarg(0))
v2 = self.getvalue(op.getarg(1))
if v2.is_constant() and v2.box.getint() == 0:
- self.make_equal_to(op.result, v1)
+ self.make_equal_to(op, v1)
elif v1.is_constant() and v1.box.getint() == 0:
op = op.copy_and_change(rop.INT_NEG, args=[v2.box])
self.emit_operation(op)
@@ -128,9 +129,9 @@
# If one side of the op is 0 the result is the other side.
if v1.is_constant() and v1.box.getint() == 0:
- self.make_equal_to(op.result, v2)
+ self.make_equal_to(op, v2)
elif v2.is_constant() and v2.box.getint() == 0:
- self.make_equal_to(op.result, v1)
+ self.make_equal_to(op, v1)
else:
self.emit_operation(op)
self.pure(rop.INT_ADD, [op.getarg(1), op.getarg(0)], op)
@@ -144,9 +145,9 @@
# If one side of the op is 1 the result is the other side.
if v1.is_constant() and v1.box.getint() == 1:
- self.make_equal_to(op.result, v2)
+ self.make_equal_to(op, v2)
elif v2.is_constant() and v2.box.getint() == 1:
- self.make_equal_to(op.result, v1)
+ self.make_equal_to(op, v1)
elif (v1.is_constant() and v1.box.getint() == 0) or \
(v2.is_constant() and v2.box.getint() == 0):
self.make_constant_int(op, 0)
@@ -166,7 +167,7 @@
v2 = self.getvalue(op.getarg(1))
if v2.is_constant() and v2.box.getint() == 1:
- self.make_equal_to(op.result, v1)
+ self.make_equal_to(op, v1)
else:
self.emit_operation(op)
@@ -175,7 +176,7 @@
v2 = self.getvalue(op.getarg(1))
if v2.is_constant() and v2.box.getint() == 0:
- self.make_equal_to(op.result, v1)
+ self.make_equal_to(op, v1)
elif v1.is_constant() and v1.box.getint() == 0:
self.make_constant_int(op, 0)
else:
@@ -186,7 +187,7 @@
v2 = self.getvalue(op.getarg(1))
if v2.is_constant() and v2.box.getint() == 0:
- self.make_equal_to(op.result, v1)
+ self.make_equal_to(op, v1)
elif v1.is_constant() and v1.box.getint() == 0:
self.make_constant_int(op, 0)
else:
@@ -197,9 +198,9 @@
v2 = self.getvalue(op.getarg(1))
if v1.is_constant() and v1.box.getint() == 0:
- self.make_equal_to(op.result, v2)
+ self.make_equal_to(op, v2)
elif v2.is_constant() and v2.box.getint() == 0:
- self.make_equal_to(op.result, v1)
+ self.make_equal_to(op, v1)
else:
self.emit_operation(op)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit