LucidDB / luciddb

DEFUNCT: See README
https://github.com/LucidDB/luciddb
Apache License 2.0
52 stars 24 forks source link

[FRG-25] Case statement too eagerly optimizes common sub-expressions #845

Open dynamobi-build opened 12 years ago

dynamobi-build commented 12 years ago

[reporter="jpham", created="Mon, 23 Jan 2006 15:25:27 -0500 (GMT-05:00)"] When it is translating a program, the translator avoids translating the
same expression twice. (via implementNode()) For example, if you do:

  values 5_10, 5_10;

It only codes 5_10 once. This is usually the right thing. However, it
has implications for conditional code. Consider the expression:

  if ($0) {
    5_10;
  } else {
    5_10+2;
  }

The common sub-expression would undefined for the "else" clause. In Rex,
this is represented as:

  Case($0, 5_10, 5_10+2)

This gets translated to roughly the following Fennel calculator code:

0: if not $0 jump 4
1: L0 = 5_10
2: L1 = L0
3: jump 5
4: L1 = L0 + 2
5: return L1

I am putting in some code to scope the conditional value expressions.
It would be good to have someone double check it and make
sure it was ok.

dynamobi-build commented 12 years ago

[author="johnk", created="Mon, 23 Jan 2006 15:28:14 -0500 (GMT-05:00)"] Edan, please triage. I don't know who is handling program builder issues, but it isn't me.

dynamobi-build commented 12 years ago

[author="edan", created="Tue, 24 Jan 2006 10:00:31 -0500 (GMT-05:00)"] I believe Angel is right person to fix this. Please correct me if I am wrong, Angel.