Skip to content

Commit

Permalink
Add EarlyCSEPass before InstCombinePass (google#1339)
Browse files Browse the repository at this point in the history
It prevents InstCombinePass from obfuscating MADs in some cases.
  • Loading branch information
olvaffe committed Apr 30, 2024
1 parent 118d65e commit 1f655d7
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/InstCombine/InstCombine.h"
#include "llvm/Transforms/Scalar/DCE.h"
#include "llvm/Transforms/Scalar/EarlyCSE.h"
#include "llvm/Transforms/Scalar/InferAddressSpaces.h"
#include "llvm/Transforms/Scalar/SROA.h"
#include "llvm/Transforms/Scalar/StructurizeCFG.h"
Expand Down Expand Up @@ -590,6 +591,7 @@ int RunPassPipeline(llvm::Module &M, llvm::raw_svector_ostream *binaryStream) {
// See https://github.com/google/clspv/issues/71
pm.addPass(clspv::HideConstantLoadsPass());

pm.addPass(llvm::createModuleToFunctionPassAdaptor(llvm::EarlyCSEPass()));
pm.addPass(
llvm::createModuleToFunctionPassAdaptor(llvm::InstCombinePass()));

Expand Down

0 comments on commit 1f655d7

Please sign in to comment.