llvm-gcc4: Enable various optimizations at -O1/-O2

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

llvm-gcc4: Enable various optimizations at -O1/-O2

Devang Patel
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
+  }

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev