diff: additions to const_prop.m
Simon Taylor
stayl at cs.mu.OZ.AU
Tue Mar 30 15:56:56 AEST 1999
Estimated hours taken: 0.1
compiler/const_prop.m:
Optimize `int:unchecked_left_shift/2', `int:unchecked_right_shift/2'
and `int:rem/2'.
Note: the bug with division by zero for `rem' and `mod' is fixed in
my next commit.
Index: const_prop.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/const_prop.m,v
retrieving revision 1.6
diff -u -u -r1.6 const_prop.m
--- const_prop.m 1998/11/20 04:07:14 1.6
+++ const_prop.m 1999/03/30 05:34:53
@@ -191,16 +191,36 @@
YVal is XVal // ZVal.
****/
+ % This isn't actually a builtin.
evaluate_builtin_tri("int", "mod", 0, X, Y, Z, Z, int_const(ZVal)) :-
X = _XVar - bound(_XUniq, [functor(int_const(XVal), [])]),
Y = _YVar - bound(_YUniq, [functor(int_const(YVal), [])]),
ZVal is XVal mod YVal.
+evaluate_builtin_tri("int", "rem", 0, X, Y, Z, Z, int_const(ZVal)) :-
+ X = _XVar - bound(_XUniq, [functor(int_const(XVal), [])]),
+ Y = _YVar - bound(_YUniq, [functor(int_const(YVal), [])]),
+ ZVal is XVal rem YVal.
+
+evaluate_builtin_tri("int", "unchecked_left_shift",
+ 0, X, Y, Z, Z, int_const(ZVal)) :-
+ X = _XVar - bound(_XUniq, [functor(int_const(XVal), [])]),
+ Y = _YVar - bound(_YUniq, [functor(int_const(YVal), [])]),
+ ZVal is unchecked_left_shift(XVal, YVal).
+
+ % This isn't actually a builtin.
evaluate_builtin_tri("int", "<<", 0, X, Y, Z, Z, int_const(ZVal)) :-
X = _XVar - bound(_XUniq, [functor(int_const(XVal), [])]),
Y = _YVar - bound(_YUniq, [functor(int_const(YVal), [])]),
ZVal is XVal << YVal.
+evaluate_builtin_tri("int", "unchecked_right_shift",
+ 0, X, Y, Z, Z, int_const(ZVal)) :-
+ X = _XVar - bound(_XUniq, [functor(int_const(XVal), [])]),
+ Y = _YVar - bound(_YUniq, [functor(int_const(YVal), [])]),
+ ZVal is unchecked_right_shift(XVal, YVal).
+
+ % This isn't actually a builtin.
evaluate_builtin_tri("int", ">>", 0, X, Y, Z, Z, int_const(ZVal)) :-
X = _XVar - bound(_XUniq, [functor(int_const(XVal), [])]),
Y = _YVar - bound(_YUniq, [functor(int_const(YVal), [])]),
More information about the developers
mailing list