caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: Radu Grigore <radugrigore@gmail.com>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
	caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Re: paralell assignment problem
Date: 09 Feb 2005 21:11:22 +1100	[thread overview]
Message-ID: <1107943881.5022.508.camel@pelican.wigram> (raw)
In-Reply-To: <7f8e92aa05020823485b62fcde@mail.gmail.com>

On Wed, 2005-02-09 at 18:48, Radu Grigore wrote:
> On Tue, 8 Feb 2005 20:33:52 +0200, Radu Grigore <radugrigore@gmail.com> wrote:
> > On Tue, 08 Feb 2005 09:12:32 -0800 (PST), skaller
> > <skaller@users.sourceforge.net> wrote:
> > 
> > > However it isn't clear (to me) that just picking an arbitrary
> > > assignment to split into two using a temporary
> > > actually minimises the number of temporaries.
> > 
> > I'm mildly convinced that it works.
> 
> I was obviously too tired yesterday: there are lots of mistakes in my argument.
> 
> Actually here is an example on which your algorithm uses more
> assignments than necessary:
> 
> a = b+c
> b = c
> c = a+b
> 
> The solution is
> t = c
> c = a+b
> a = b+t
> b = t

That's confirmed, my algorithm produces this:

ASG _tmp_a<2009> = (Int::add (f::b, f::c))
ASG _tmp_c<2010> = (Int::add (f::a, f::b))
ASG b<1764> = f::c
ASG c<1765> = index_2010
ASG a<1763> = index_2009

However, your solution, whilst correct, breaks one of
the rules: one of the RHS is refering to the old value
of 'c' using the name 't'. The original rules required
only assignments using the original LHS variables,
the original RHS expressions, and the temporaries,
that is, only permitted buffering the RHS expressions,
not old values of variables.

Allowing *both* RHS expressions (new values of variables)
and LHS variables (old values of variables) makes sense,
however, as your example demonstrates. And also seems
to make solving the problem harder :)

-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net




  reply	other threads:[~2005-02-09 10:11 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-08  3:07 skaller
2005-02-08 14:34 ` Stefan Monnier
2005-02-08 16:02   ` [Caml-list] " skaller
2005-02-08 18:20     ` Stefan Monnier
2005-02-08 17:08   ` skaller
2005-02-08 18:33     ` Radu Grigore
2005-02-09  7:48       ` Radu Grigore
2005-02-09 10:11         ` skaller [this message]
2005-02-09  9:43       ` Radu Grigore
2005-02-09 11:19         ` Radu Grigore
2005-02-09 11:34         ` Pascal Zimmer
2005-02-09 13:53           ` skaller
2005-02-08 16:03 ` [Caml-list] " Florian Hars
2005-02-08 17:38   ` skaller
2005-02-08 16:29 ` Marcin 'Qrczak' Kowalczyk
2005-02-08 17:55   ` skaller
2005-02-08 18:32     ` Marcin 'Qrczak' Kowalczyk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1107943881.5022.508.camel@pelican.wigram \
    --to=skaller@users.sourceforge.net \
    --cc=caml-list@inria.fr \
    --cc=monnier@iro.umontreal.ca \
    --cc=radugrigore@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).