optimizer: enable movement of constants that shouldn't be duplicated

Closes PR 14531
This commit is contained in:
Matthew Flatt 2014-05-28 18:35:15 +01:00
parent d2d9b2cce3
commit dad9d001e1
2 changed files with 12 additions and 2 deletions

View File

@ -1565,6 +1565,11 @@
(check '(case-lambda [() 1] [(x y) x]) '(0 2) '(1 3)) (check '(case-lambda [() 1] [(x y) x]) '(0 2) '(1 3))
(check '(lambda (x [y #f]) y) '(1 2) '(0 3))) (check '(lambda (x [y #f]) y) '(1 2) '(0 3)))
(test-comp '(lambda ()
(let ([l '(1 2)])
(car l)))
'(lambda () 1))
(let ([test-dropped (let ([test-dropped
(lambda (cons-name . args) (lambda (cons-name . args)
(test-comp `(let ([x 5]) (test-comp `(let ([x 5])
@ -1666,7 +1671,8 @@
(test-move '(cons 1 2 3) #f) (test-move '(cons 1 2 3) #f)
(test-move '(mcons 1 2 3) #f) (test-move '(mcons 1 2 3) #f)
(test-move '(box 1 2) #f) (test-move '(box 1 2) #f)
(test-move '(box-immutable 1 2) #f))) (test-move '(box-immutable 1 2) #f)
(test-move '(quote (1 2)) #t)))
;; Check move in to `else` branch where `then` ;; Check move in to `else` branch where `then`
;; branch might capture a continuation ;; branch might capture a continuation

View File

@ -911,7 +911,7 @@ Scheme_Object *scheme_make_struct_proc_shape(intptr_t k)
} }
static int single_valued_noncm_expression(Scheme_Object *expr, int fuel) static int single_valued_noncm_expression(Scheme_Object *expr, int fuel)
/* Non-omittable but single-valued expresions that are not sensitive /* Non-omittable/non-copyable but single-valued expresions that are not sensitive
to being in tail position. */ to being in tail position. */
{ {
Scheme_Object *rator = NULL; Scheme_Object *rator = NULL;
@ -938,6 +938,10 @@ static int single_valued_noncm_expression(Scheme_Object *expr, int fuel)
} }
} }
break; break;
default:
if (SCHEME_TYPE(expr) > _scheme_compiled_values_types_)
return 1;
break;
} }
if (rator && SCHEME_PRIMP(rator)) { if (rator && SCHEME_PRIMP(rator)) {