optimizer: fix inference bug

The optimizer's inference that could incorrectly that that a
conditional produced a flonum (when it actually produced a fixnum or a
fixnum in one branch and flonum in the other).
This commit is contained in:
Matthew Flatt 2014-05-30 18:36:22 +01:00
parent 948a709b47
commit 2eef2ce409
2 changed files with 18 additions and 2 deletions

View File

@ -3711,6 +3711,16 @@
(test 'c dynamic-require ''check-jit-registers-shortcut 'result)
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Check (non-)inference of flonums with `if` branches:
(let ()
(define f (lambda (x)
(let ([v (if x 1 2.0)])
(fl+ v v))))
(set! f f)
(err/rt-test (f #t)))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(report-errs)

View File

@ -2021,8 +2021,14 @@ static int expr_produces_local_type(Scheme_Object *expr, int fuel)
case scheme_branch_type:
{
Scheme_Branch_Rec *b = (Scheme_Branch_Rec *)expr;
return (expr_produces_local_type(b->tbranch, fuel / 2)
&& expr_produces_local_type(b->fbranch, fuel / 2));
int t1, t2;
t1 = expr_produces_local_type(b->tbranch, fuel / 2);
if (t1) {
t2 = expr_produces_local_type(b->fbranch, fuel / 2);
return ((t1 == t2) ? t1 : 0);
} else
return 0;
}
break;
case scheme_sequence_type: