Skip to content

Commit

Permalink
adding new list of optimization passes
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jun 19, 2011
1 parent 02f6a2d commit 2ee9806
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
5 changes: 2 additions & 3 deletions j/complex.j
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ integer_valued(z::ComplexNum) = (real_valued(z) && integer_valued(real(z)))
real(x::Real) = x
imag(x::Real) = convert(typeof(x), 0)

==(z::ComplexNum, w::ComplexNum) = (real(z) == real(w) &&
imag(z) == imag(w))

function show(c::ComplexNum)
show(real(c))
i = imag(c)
Expand Down Expand Up @@ -136,6 +133,8 @@ pi{T}(::Type{Complex{T}}) = pi(T)

## functions of complex numbers ##

==(z::ComplexNum, w::ComplexNum) = (real(z) == real(w) && imag(z) == imag(w))

conj(z::ComplexNum) = complex(real(z),-imag(z))
norm(z::ComplexNum) = square(real(z)) + square(imag(z))
abs(z::ComplexNum) = hypot(real(z), imag(z))
Expand Down
45 changes: 45 additions & 0 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1587,6 +1587,12 @@ extern "C" jl_value_t *jl_new_box(jl_value_t *v)
return box;
}

static void addPass(FunctionPassManager *PM, Pass *P)
{
// Add the pass to the pass manager...
PM->add(P);
}

static void init_julia_llvm_env(Module *m)
{
T_int1 = Type::getInt1Ty(getGlobalContext());
Expand Down Expand Up @@ -1787,6 +1793,44 @@ static void init_julia_llvm_env(Module *m)
// set up optimization passes
FPM = new FunctionPassManager(jl_Module);
FPM->add(new TargetData(*jl_ExecutionEngine->getTargetData()));

// list of passes from vmkit
/*
addPass(FPM, createCFGSimplificationPass()); // Clean up disgusting code
addPass(FPM, createPromoteMemoryToRegisterPass());// Kill useless allocas
addPass(FPM, createInstructionCombiningPass()); // Cleanup for scalarrepl.
addPass(FPM, createScalarReplAggregatesPass()); // Break up aggregate allocas
addPass(FPM, createInstructionCombiningPass()); // Cleanup for scalarrepl.
addPass(FPM, createJumpThreadingPass()); // Thread jumps.
addPass(FPM, createCFGSimplificationPass()); // Merge & remove BBs
addPass(FPM, createInstructionCombiningPass()); // Combine silly seq's
addPass(FPM, createCFGSimplificationPass()); // Merge & remove BBs
addPass(FPM, createReassociatePass()); // Reassociate expressions
addPass(FPM, createLoopRotatePass()); // Rotate loops.
addPass(FPM, createLICMPass()); // Hoist loop invariants
addPass(FPM, createLoopUnswitchPass()); // Unswitch loops.
addPass(FPM, createInstructionCombiningPass());
addPass(FPM, createIndVarSimplifyPass()); // Canonicalize indvars
addPass(FPM, createLoopDeletionPass()); // Delete dead loops
addPass(FPM, createLoopUnrollPass()); // Unroll small loops
addPass(FPM, createLoopStrengthReducePass()); // (jwb added)
addPass(FPM, createInstructionCombiningPass()); // Clean up after the unroller
addPass(FPM, createGVNPass()); // Remove redundancies
addPass(FPM, createMemCpyOptPass()); // Remove memcpy / form memset
addPass(FPM, createSCCPPass()); // Constant prop with SCCP
// Run instcombine after redundancy elimination to exploit opportunities
// opened up by them.
addPass(FPM, createInstructionCombiningPass());
addPass(FPM, createJumpThreadingPass()); // Thread jumps
addPass(FPM, createDeadStoreEliminationPass()); // Delete dead stores
addPass(FPM, createAggressiveDCEPass()); // Delete dead instructions
addPass(FPM, createCFGSimplificationPass()); // Merge & remove BBs
*/

FPM->add(createCFGSimplificationPass());
FPM->add(createPromoteMemoryToRegisterPass());
FPM->add(createInstructionCombiningPass());
Expand All @@ -1799,6 +1843,7 @@ static void init_julia_llvm_env(Module *m)
FPM->add(createSCCPPass());
FPM->add(createDeadStoreEliminationPass());
//llvm::createStandardFunctionPasses(FPM, 2);

FPM->doInitialization();
}

Expand Down

0 comments on commit 2ee9806

Please sign in to comment.