Browse Source

Add more llvm optimization passes (#445)

Add more llvm optimization passes to improve AOT/JIT performance
Wenyong Huang 5 years ago
parent
commit
f4770ae8c8
2 changed files with 16 additions and 0 deletions
  1. 14 0
      core/iwasm/compilation/aot_llvm.c
  2. 2 0
      core/iwasm/compilation/aot_llvm.h

+ 14 - 0
core/iwasm/compilation/aot_llvm.c

@@ -1401,6 +1401,20 @@ aot_create_comp_context(AOTCompData *comp_data,
     LLVMAddCFGSimplificationPass(comp_ctx->pass_mgr);
     LLVMAddJumpThreadingPass(comp_ctx->pass_mgr);
     LLVMAddConstantPropagationPass(comp_ctx->pass_mgr);
+    LLVMAddIndVarSimplifyPass(comp_ctx->pass_mgr);
+
+    if (!option->is_jit_mode) {
+        LLVMAddLoopRotatePass(comp_ctx->pass_mgr);
+        LLVMAddLoopUnswitchPass(comp_ctx->pass_mgr);
+        LLVMAddInstructionCombiningPass(comp_ctx->pass_mgr);
+        LLVMAddCFGSimplificationPass(comp_ctx->pass_mgr);
+        LLVMAddGVNPass(comp_ctx->pass_mgr);
+        LLVMAddLICMPass(comp_ctx->pass_mgr);
+        LLVMAddLoopVectorizePass(comp_ctx->pass_mgr);
+        LLVMAddSLPVectorizePass(comp_ctx->pass_mgr);
+        LLVMAddInstructionCombiningPass(comp_ctx->pass_mgr);
+        LLVMAddCFGSimplificationPass(comp_ctx->pass_mgr);
+    }
 
     /* Create metadata for llvm float experimental constrained intrinsics */
     if (!(comp_ctx->fp_rounding_mode =

+ 2 - 0
core/iwasm/compilation/aot_llvm.h

@@ -13,7 +13,9 @@
 #include "llvm-c/Object.h"
 #include "llvm-c/ExecutionEngine.h"
 #include "llvm-c/Analysis.h"
+#include "llvm-c/Transforms/Utils.h"
 #include "llvm-c/Transforms/Scalar.h"
+#include "llvm-c/Transforms/Vectorize.h"
 
 #ifdef __cplusplus
 extern "C" {