From 8948388ec53ea8882ada35384ad895ecd45f208f Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Tue, 2 Apr 2013 13:40:04 -0400 Subject: [PATCH] Fix another unsafe optimization of unsafe-fxmodulo. Found using random testing. --- collects/tests/racket/unsafe.rktl | 1 + src/racket/src/optimize.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/collects/tests/racket/unsafe.rktl b/collects/tests/racket/unsafe.rktl index 49d4d359d3..16732fd689 100644 --- a/collects/tests/racket/unsafe.rktl +++ b/collects/tests/racket/unsafe.rktl @@ -92,6 +92,7 @@ (test-bin 0 'unsafe-fxmodulo 0 -5) (test-bin 0 'unsafe-fxmodulo 10 1) (err/rt-test (unsafe-fxmodulo (error "bad") 1) exn:fail?) ; not 0 + (err/rt-test (unsafe-fxmodulo 0 (error "bad")) exn:fail?) ; not 0 (test-bin 3.4 'unsafe-fl+ 1.4 2.0) (test-bin -1.1 'unsafe-fl+ 1.0 -2.1) diff --git a/src/racket/src/optimize.c b/src/racket/src/optimize.c index 2efaa9ab69..b797fd1180 100644 --- a/src/racket/src/optimize.c +++ b/src/racket/src/optimize.c @@ -2642,7 +2642,7 @@ static Scheme_Object *finish_optimize_application3(Scheme_App3_Rec *app, Optimiz return app->rand1; } else if (IS_NAMED_PRIM(app->rator, "unsafe-fxremainder") || IS_NAMED_PRIM(app->rator, "unsafe-fxmodulo")) { - if (z1) + if (z1 && scheme_omittable_expr(app->rand2, 1, 20, 0, info, NULL, -1, 0)) return scheme_make_integer(0); if (SAME_OBJ(app->rand2, scheme_make_integer(1)) && scheme_omittable_expr(app->rand1, 1, 20, 0, info, NULL, -1, 0))