Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[optimization] Combine load elimination with SsaInstrReducer for better results #303

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions aeneas/src/ir/SsaNormalizer.v3
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,9 @@ class SsaRaNormalizer extends SsaRebuilder {
//TODO SsaGraphVerifier.new(context).verify();
if (context.compiler.NormOptimize) {
var opt = SsaOptimizer.new(context);
opt.iopt.optimize_loads = context.compiler.LoadOptimize;
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
7 changes: 1 addition & 6 deletions aeneas/src/main/Compiler.v3
Original file line number Diff line number Diff line change
Expand Up @@ -341,15 +341,10 @@ 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);
opt.iopt.optimize_loads = compiler.LoadOptimize;
opt.optGraph();
context.printSsa("Postpass Optimized");
}
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.1772";
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