trivial diff: modulus by zero in const_prop.m

Simon Taylor stayl at cs.mu.OZ.AU
Tue Mar 30 15:57:44 AEST 1999


Estimated hours taken: 0.1

compiler/const_prop.m:
	Don't divide by zero when optimizing `int:rem/2' and `int:mod/2'.


Index: const_prop.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/const_prop.m,v
retrieving revision 1.7
diff -u -u -r1.7 const_prop.m
--- const_prop.m	1999/03/30 05:38:49	1.7
+++ const_prop.m	1999/03/30 05:47:17
@@ -195,11 +195,13 @@
 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), [])]),
+	YVal \= 0,
 	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), [])]),
+	YVal \= 0,
 	ZVal is XVal rem YVal.
 
 evaluate_builtin_tri("int", "unchecked_left_shift",



More information about the developers mailing list