chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] [PATCH] do not merge results when conditional branches


From: Felix
Subject: [Chicken-hackers] [PATCH] do not merge results when conditional branches differ in the number of result values
Date: Mon, 14 Nov 2011 14:36:18 +0100 (CET)

When, during flow-analysis, the branches of a conditional expression differ
in the number of result-values, the types where incorrectly merged, defaulting
to the union of both branch results and cutting off the longer result-value
sequence. In a "call-with-values" invocation with two result values, the
cutoff could produce a single-valued result, triggering an optimization
rule for this case (which replaces invocations to "call-with-values", where
the thunk is known to produce a single result, with a simpler code
sequence). The change disables the merge in this case and simply treats
the expression as having an unknown number of results, which will not
trigger the optimization rule.

This patch fixes #680.
>From c0776e62e23c2aa75d6c751be87c7bf22cd14ff4 Mon Sep 17 00:00:00 2001
From: felix <address@hidden>
Date: Mon, 14 Nov 2011 14:30:36 +0100
Subject: [PATCH] when conditional branches differ in the number of results, do 
not merge the results - treat the expression as returning an undetermined 
number of unknown results

---
 scrutinizer.scm |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/scrutinizer.scm b/scrutinizer.scm
index 1854303..2f8ed8f 100755
--- a/scrutinizer.scm
+++ b/scrutinizer.scm
@@ -500,15 +500,16 @@
                                   (add-to-blist (caar ble) (car flow) (cdr 
ble))))
                               blist)))
                          (cond ((and (not (eq? '* r1)) (not (eq? '* r2)))
-                                (when (and (not nor1) (not nor2)
-                                           (not (= (length r1) (length r2))))
-                                  (report 
-                                   loc
-                                   (sprintf
-                                       "branches in conditional expression 
differ in the number of results:~%~%~a"
-                                     (pp-fragment n))))
                                 ;;(dd " branches: ~s:~s / ~s:~s" nor1 r1 nor2 
r2)
-                                (cond (nor1 r2)
+                                (cond ((and (not nor1) (not nor2)
+                                            (not (= (length r1) (length r2))))
+                                       (report 
+                                        loc
+                                        (sprintf
+                                            "branches in conditional 
expression differ in the number of results:~%~%~a"
+                                          (pp-fragment n)))
+                                       '*)
+                                      (nor1 r2)
                                       (nor2 r1)
                                       (else
                                        (dd "merge branch results: ~s + ~s" r1 
r2)
-- 
1.6.0.4


reply via email to

[Prev in Thread] Current Thread [Next in Thread]