Commit cacba274 authored by zygzagZ's avatar zygzagZ

Further bool lazy eval fixes and proper alloc register preservation

parent c938ad6f
...@@ -261,7 +261,7 @@ void Compiler::generateQAlloc(QAlloc &q) { ...@@ -261,7 +261,7 @@ void Compiler::generateQAlloc(QAlloc &q) {
append("PUSHL", "$" + to_string(q.size)); append("PUSHL", "$" + to_string(q.size));
append("CALL", q.count ? "__latte_mem_init_array" : "__latte_mem_init"); append("CALL", q.count ? "__latte_mem_init_array" : "__latte_mem_init");
append("ADDL", "$" + to_string(q.count ? 12 : 8), "%esp"); append("ADDL", "$8", "%esp");
for (auto r = saveRegs.rbegin(); r != saveRegs.rend(); r++) { for (auto r = saveRegs.rbegin(); r != saveRegs.rend(); r++) {
if (*r != Register(q.loc)) { if (*r != Register(q.loc)) {
......
...@@ -244,6 +244,7 @@ void QuadrupleGenerator::visitEAnd(EAnd *p) { ...@@ -244,6 +244,7 @@ void QuadrupleGenerator::visitEAnd(EAnd *p) {
leftValBlock->quads.pop_back(); leftValBlock->quads.pop_back();
// could merge basic blocks now, but why bother // could merge basic blocks now, but why bother
if (r) { if (r) {
if (labelTrue && r->constExpr && r->val == 1) addQuad<QJump>(labelTrue);
lastVar = r->val ? l : r; lastVar = r->val ? l : r;
} }
} else { } else {
...@@ -254,12 +255,10 @@ void QuadrupleGenerator::visitEAnd(EAnd *p) { ...@@ -254,12 +255,10 @@ void QuadrupleGenerator::visitEAnd(EAnd *p) {
rightValBlock->append(block); rightValBlock->append(block);
leftValBlock->append(block); leftValBlock->append(block);
lastVar = alloc();
if (!labelTrue || !labelFalse) { if (!labelTrue || !labelFalse) {
lastVar = alloc();
block->addPhi(rightValBlock, lastVar, r); block->addPhi(rightValBlock, lastVar, r);
block->addPhi(leftValBlock, lastVar, l); block->addPhi(leftValBlock, lastVar, l);
} else {
lastVar = nullptr;
} }
} }
} }
...@@ -287,6 +286,8 @@ void QuadrupleGenerator::visitEOr(EOr *p) { ...@@ -287,6 +286,8 @@ void QuadrupleGenerator::visitEOr(EOr *p) {
leftValBlock->quads.pop_back(); leftValBlock->quads.pop_back();
// could merge basic blocks now, but why bother // could merge basic blocks now, but why bother
if (r) { if (r) {
// qjump labelFalse if r->constExpr && r->val == 0 && labelFalse
if (labelFalse && r->constExpr && r->val == 0) addQuad<QJump>(labelFalse);
lastVar = r->val ? r : l; lastVar = r->val ? r : l;
} }
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment