[X86] Add option for enabling LEA optimization pass, by Andrey Turetsky
authorAlexey Bataev <a.bataev@hotmail.com>
Thu, 17 Dec 2015 07:34:39 +0000 (07:34 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Thu, 17 Dec 2015 07:34:39 +0000 (07:34 +0000)
Add option to enable/disable LEA optimization pass. By default the pass is disabled.
Differential Revision: http://reviews.llvm.org/D15573

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255881 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86OptimizeLEAs.cpp
test/CodeGen/X86/lea-opt.ll

index da83c8ad824803b9e258a76741aed89675fb702e..58020d909a43f8fccf0bae29688a804a77a5f275 100644 (file)
@@ -33,6 +33,10 @@ using namespace llvm;
 
 #define DEBUG_TYPE "x86-optimize-LEAs"
 
+static cl::opt<bool> EnableX86LEAOpt("enable-x86-lea-opt", cl::Hidden,
+                                     cl::desc("X86: Enable LEA optimizations."),
+                                     cl::init(false));
+
 STATISTIC(NumSubstLEAs, "Number of LEA instruction substitutions");
 
 namespace {
@@ -296,7 +300,7 @@ bool OptimizeLEAPass::runOnMachineFunction(MachineFunction &MF) {
   bool Changed = false;
 
   // Perform this optimization only if we care about code size.
-  if (!MF.getFunction()->optForSize())
+  if (!EnableX86LEAOpt || !MF.getFunction()->optForSize())
     return false;
 
   MRI = &MF.getRegInfo();
index c105b31995b3db0cccb40aacb38b5857f4deea68..571f2d9084c4dcc2aa4d1d6353ec1dd652dc22aa 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s
+; RUN: llc < %s -mtriple=x86_64-linux -enable-x86-lea-opt | FileCheck %s
 
 %struct.anon1 = type { i32, i32, i32 }
 %struct.anon2 = type { i32, [32 x i32], i32 }