Devang Patel
2006-Sep-03 06:40 UTC
[LLVMdev] llvm-gcc4: Enable various optimizations at -O1/-O2
Hi All, I have installed llvm-gcc4 patch to enable various llvm optimizations at -O1/-O2/-O3. This means instead of $ llvm-gcc4 --emit-llvm foo.c -o foo.bc $ opt foo.bc -o foo_optimized.bc $ llc foo_optimized.bc -o foo.o One can directly use $ llvm-gcc4 -O2 foo.c -o foo.o to get optimized foo.o - Devang + + if (optimize > 0) { + + + PerModulePasses->add(createRaiseAllocationsPass()); // call % malloc -> malloc inst + PerModulePasses->add(createCFGSimplificationPass()); // Clean up disgusting code + PerModulePasses->add(createPromoteMemoryToRegisterPass());// Kill useless allocas + PerModulePasses->add(createGlobalOptimizerPass()); // Optimize out global vars + PerModulePasses->add(createGlobalDCEPass()); // Remove unused fns and globs + PerModulePasses->add(createIPConstantPropagationPass());// IP Constant Propagation + PerModulePasses->add(createDeadArgEliminationPass()); // Dead argument elimination + PerModulePasses->add(createInstructionCombiningPass()); // Clean up after IPCP & DAE + PerModulePasses->add(createCFGSimplificationPass()); // Clean up after IPCP & DAE + PerModulePasses->add(createPruneEHPass()); // Remove dead EH info + + if (optimize > 1) { + PerModulePasses->add(createFunctionInliningPass()); // Inline small functions + PerModulePasses->add(createSimplifyLibCallsPass()); // Library Call Optimizations + + if (optimize > 2) + PerModulePasses->add(createArgumentPromotionPass()); // Scalarize uninlined fn args + + PerModulePasses->add(createRaisePointerReferencesPass());// Recover type information + } + + PerModulePasses->add(createTailDuplicationPass()); // Simplify cfg by copying code + PerModulePasses->add(createCFGSimplificationPass()); // Merge & remove BBs + PerModulePasses->add(createScalarReplAggregatesPass()); // Break up aggregate allocas + PerModulePasses->add(createInstructionCombiningPass()); // Combine silly seq's + PerModulePasses->add(createCondPropagationPass()); // Propagate conditionals + PerModulePasses->add(createTailCallEliminationPass()); // Eliminate tail calls + PerModulePasses->add(createCFGSimplificationPass()); // Merge & remove BBs + PerModulePasses->add(createReassociatePass()); // Reassociate expressions + PerModulePasses->add(createLICMPass()); // Hoist loop invariants + PerModulePasses->add(createLoopUnswitchPass()); // Unswitch loops. + PerModulePasses->add(createInstructionCombiningPass()); // Clean up after LICM/reassoc + PerModulePasses->add(createIndVarSimplifyPass()); // Canonicalize indvars + PerModulePasses->add(createLoopUnrollPass()); // Unroll small loops + PerModulePasses->add(createInstructionCombiningPass()); // Clean up after the unroller + + if (optimize > 2) + PerModulePasses->add(createLoadValueNumberingPass()); // GVN for load instructions + + PerModulePasses->add(createGCSEPass()); // Remove common subexprs + PerModulePasses->add(createSCCPPass()); // Constant prop with SCCP + + // Run instcombine after redundancy elimination to exploit opportunities + // opened up by them. + PerModulePasses->add(createInstructionCombiningPass()); + PerModulePasses->add(createCondPropagationPass()); // Propagate conditionals + PerModulePasses->add(createDeadStoreEliminationPass()); // Delete dead stores + PerModulePasses->add(createAggressiveDCEPass()); // SSA based 'Aggressive DCE' + PerModulePasses->add(createCFGSimplificationPass()); // Merge & remove BBs + + if (optimize > 1) + PerModulePasses->add(createConstantMergePass()); // Merge dup global constants + }
Apparently Analagous Threads
- [LLVMdev] Something about the andersens pass
- [LLVMdev] llvm-gcc build broken
- [LLVMdev] [Polly] Move Polly's execution later
- [LLVMdev] [Polly] Move Polly's execution later
- [LLVMdev] [Polly] Compile-time and Execution-time analysis for the SCEV canonicalization