optimize (if (if <test> #t #f) <t> <f>) to (if <test> #t #f); this pattern happens with 'and' and constant folding
svn: r14230
This commit is contained in:
parent
3e039705fa
commit
7e6dc9b40e
|
@ -2902,6 +2902,16 @@ static Scheme_Object *optimize_branch(Scheme_Object *o, Optimize_Info *info)
|
||||||
} else
|
} else
|
||||||
t = scheme_optimize_expr(t, info);
|
t = scheme_optimize_expr(t, info);
|
||||||
|
|
||||||
|
/* For test position, convert (if <expr> #t #f) to <expr> */
|
||||||
|
while (1) {
|
||||||
|
if (SAME_TYPE(SCHEME_TYPE(t), scheme_branch_type)
|
||||||
|
&& SAME_OBJ(((Scheme_Branch_Rec *)t)->tbranch, scheme_true)
|
||||||
|
&& SAME_OBJ(((Scheme_Branch_Rec *)t)->fbranch, scheme_false))
|
||||||
|
t = ((Scheme_Branch_Rec *)t)->test;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (SCHEME_TYPE(t) > _scheme_compiled_values_types_) {
|
if (SCHEME_TYPE(t) > _scheme_compiled_values_types_) {
|
||||||
if (SCHEME_FALSEP(t))
|
if (SCHEME_FALSEP(t))
|
||||||
return scheme_optimize_expr(fb, info);
|
return scheme_optimize_expr(fb, info);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user