add an option to turn on LSR.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26080 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/Sparc/SparcTargetMachine.cpp b/lib/Target/Sparc/SparcTargetMachine.cpp
index 2a2e9b4..b66ed02 100644
--- a/lib/Target/Sparc/SparcTargetMachine.cpp
+++ b/lib/Target/Sparc/SparcTargetMachine.cpp
@@ -27,6 +27,8 @@
 namespace {
   // Register the target.
   RegisterTarget<SparcTargetMachine> X("sparc", "  SPARC");
+  
+  cl::opt<bool> EnableLSR("enable-sparc-lsr", cl::Hidden);
 }
 
 /// SparcTargetMachine ctor - Create an ILP32 architecture model
@@ -65,6 +67,9 @@
                                              bool Fast) {
   if (FileType != TargetMachine::AssemblyFile) return true;
 
+  // Run loop strength reduction before anything else.
+  if (EnableLSR && !Fast) PM.add(createLoopStrengthReducePass());
+
   // FIXME: Implement efficient support for garbage collection intrinsics.
   PM.add(createLowerGCPass());
 
@@ -73,7 +78,7 @@
 
   // FIXME: implement the switch instruction in the instruction selector.
   PM.add(createLowerSwitchPass());
-
+  
   // Print LLVM code input to instruction selector:
   if (PrintMachineCode)
     PM.add(new PrintFunctionPass());