From a8fff3602112a74287886548d2fbbb7fc2c185f3 Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Thu, 17 Dec 2015 07:34:39 +0000 Subject: [PATCH] [X86] Add option for enabling LEA optimization pass, by Andrey Turetsky Add option to enable/disable LEA optimization pass. By default the pass is disabled. Differential Revision: http://reviews.llvm.org/D15573 llvm-svn: 255881 --- lib/Target/X86/X86OptimizeLEAs.cpp | 6 +++++- test/CodeGen/X86/lea-opt.ll | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Target/X86/X86OptimizeLEAs.cpp b/lib/Target/X86/X86OptimizeLEAs.cpp index da83c8ad824..58020d909a4 100644 --- a/lib/Target/X86/X86OptimizeLEAs.cpp +++ b/lib/Target/X86/X86OptimizeLEAs.cpp @@ -33,6 +33,10 @@ using namespace llvm; #define DEBUG_TYPE "x86-optimize-LEAs" +static cl::opt 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(); diff --git a/test/CodeGen/X86/lea-opt.ll b/test/CodeGen/X86/lea-opt.ll index c105b31995b..571f2d9084c 100644 --- a/test/CodeGen/X86/lea-opt.ll +++ b/test/CodeGen/X86/lea-opt.ll @@ -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 }