optimizer: allow duplication of toplevels
This commit is contained in:
parent
2d0f8f6c0f
commit
b93d94bb67
|
@ -1945,6 +1945,19 @@
|
|||
(if r #t (something-else))))
|
||||
'(lambda (x) (if (something) #t (something-else))))
|
||||
|
||||
(let ([test-if-if-reduction
|
||||
(lambda (dup)
|
||||
(test-comp `(lambda (x y z) (if (if x y #f) z ,dup))
|
||||
`(lambda (x y z) (if x (if y z ,dup) ,dup))))])
|
||||
(test-if-if-reduction 1)
|
||||
(test-if-if-reduction ''x)
|
||||
(test-if-if-reduction "x")
|
||||
(test-if-if-reduction #"x")
|
||||
(test-if-if-reduction #t)
|
||||
(test-if-if-reduction #f)
|
||||
(test-if-if-reduction 'car)
|
||||
(test-if-if-reduction 'map))
|
||||
|
||||
(let ([test-pred-implies-val
|
||||
(lambda (pred? val)
|
||||
(test-comp `(lambda (x) (if (,pred? x) ,val 0))
|
||||
|
|
|
@ -1649,6 +1649,7 @@ int scheme_ir_duplicate_ok(Scheme_Object *fb, int cross_module)
|
|||
|| SCHEME_EOFP(fb)
|
||||
|| SCHEME_INTP(fb)
|
||||
|| SCHEME_NULLP(fb)
|
||||
|| (!cross_module && SAME_TYPE(SCHEME_TYPE(fb), scheme_ir_toplevel_type))
|
||||
|| (!cross_module && SAME_TYPE(SCHEME_TYPE(fb), scheme_ir_local_type))
|
||||
|| SCHEME_PRIMP(fb)
|
||||
/* Values that are hashed by the printer and/or interned on
|
||||
|
@ -5773,9 +5774,6 @@ int scheme_is_liftable(Scheme_Object *o, Scheme_Hash_Tree *exclude_vars, int fue
|
|||
int scheme_ir_propagate_ok(Scheme_Object *value, Optimize_Info *info)
|
||||
/* Can we constant-propagate the expression `value`? */
|
||||
{
|
||||
if (scheme_ir_duplicate_ok(value, 0))
|
||||
return 1;
|
||||
|
||||
if (SAME_TYPE(SCHEME_TYPE(value), scheme_ir_lambda_type)) {
|
||||
int sz;
|
||||
sz = lambda_body_size_plus_info((Scheme_Lambda *)value, 1, info, NULL);
|
||||
|
@ -5831,8 +5829,14 @@ int scheme_ir_propagate_ok(Scheme_Object *value, Optimize_Info *info)
|
|||
if (value)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Test this after the specific cases,
|
||||
because it recognizes locals and toplevels. */
|
||||
if (scheme_ir_duplicate_ok(value, 0))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user