Skip to content

Commit

Permalink
[optimization] Combine load elimination with SsaInstrReducer for bett…
Browse files Browse the repository at this point in the history
…er results
  • Loading branch information
titzer committed Nov 22, 2024
1 parent dbe928b commit 6270ee0
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 177 deletions.
6 changes: 0 additions & 6 deletions aeneas/src/ir/SsaNormalizer.v3
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ class SsaRaNormalizer extends SsaRebuilder {
var opt = SsaOptimizer.new(context);
opt.optGraph();
context.printSsa("Norm Optimized");
if (context.compiler.LoadOptimize) {
// Perform load elimination.
if (SsaLoadOptimizer.new(context).optimize()) {
context.printSsa("Load Optimized");
}
}
//TODO SsaGraphVerifier.new(context).verify();
}
}
Expand Down
4 changes: 2 additions & 2 deletions aeneas/src/mach/MachLowering.v3
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ class MachLowering(mach: MachProgram, compiler: Compiler, config: MachLoweringCo
}
}
def doBlock(block: SsaBlock) {
curBlock.clear();
context.block = curBlock.block = block;
context.block = block;
curBlock.set(block);
var i = block.next;
while (true) {
if (i == null) break;
Expand Down
6 changes: 0 additions & 6 deletions aeneas/src/main/Compiler.v3
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,6 @@ class Compilation(compiler: Compiler, prog: Program) {
SsaCfOptimizer.new(context).optimize();
context.printSsa("Control Optimized");
}
if (compiler.LoadOptimize) {
// Perform load elimination.
if (SsaLoadOptimizer.new(context).optimize()) {
context.printSsa("Load Optimized");
}
}
if (compiler.PostpassOptimize) {
// Run the post-pass optimizer.
var opt = SsaOptimizer.new(context);
Expand Down
2 changes: 1 addition & 1 deletion aeneas/src/main/Version.v3
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

// Updated by VCS scripts. DO NOT EDIT.
component Version {
def version: string = "III-7.1770";
def version: string = "III-7.1771";
var buildData: string;
}
7 changes: 2 additions & 5 deletions aeneas/src/ssa/SsaBuilder.v3
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ def checkInputs(inputs: Array<SsaInstr>) {
for (i in inputs) if (i == null) return V3.fail("null input");
}

def NEW_OPTIMIZER = false;
def N = Facts.NONE;
// Support class for constructing SSA instruction-by-instruction.
class SsaBuilder extends SsaBlockState {
class SsaBuilder {
def context: SsaContext;
def graph: SsaGraph;
var block: SsaBlock;
var pt: SsaLink;
var opt: SsaOptimizer;
var source: Source;
var end: bool;

new(context, graph, block) { }

Expand All @@ -37,7 +37,6 @@ class SsaBuilder extends SsaBlockState {
var i = SsaApplyOp.new(source, op, args);
i.setFact(Opcodes.facts(op.opcode));
append(i);
if (NEW_OPTIMIZER && opt != null) return opt.reduceApply(this, i);
return i;
}
def addApplyF(op: Operator, args: Array<SsaInstr>, facts: Fact.set) -> SsaInstr {
Expand All @@ -50,7 +49,6 @@ class SsaBuilder extends SsaBlockState {
var i = SsaApplyOp.new(source, op, args);
i.setFact(Opcodes.facts(op.opcode) | facts);
append(i);
if (NEW_OPTIMIZER && opt != null) return opt.reduceApply(this, i);
return i;
}
def addApplyVst(source: Source, op: Operator, vst: VstOperator, args: Array<SsaInstr>) -> SsaInstr {
Expand Down Expand Up @@ -376,7 +374,6 @@ class SsaBuilder extends SsaBlockState {
end = true;
var i = SsaIf.new(cond, tblock, fblock);
append(i);
if (NEW_OPTIMIZER && opt != null) opt.reduceIf(this, i);
}
def addSelect(t: Type, cond: SsaInstr, tval: SsaInstr, fval: SsaInstr) -> SsaInstr {
if (Debug.PARANOID) { checkInputs([cond, tval, fval]); }
Expand Down
Loading

0 comments on commit 6270ee0

Please sign in to comment.