aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2010-08-06 01:32:48 +0000
committerBill Wendling <isanbard@gmail.com>2010-08-06 01:32:48 +0000
commite4ddbdfd3cf031034020671d03626f0373fbd5ca (patch)
tree6f2a410521d3378fe204476415e5ba036c7ed9dc /include
parent5759b9b8be05293e848308f01c6eeff70d2ce15d (diff)
downloadexternal_llvm-e4ddbdfd3cf031034020671d03626f0373fbd5ca.zip
external_llvm-e4ddbdfd3cf031034020671d03626f0373fbd5ca.tar.gz
external_llvm-e4ddbdfd3cf031034020671d03626f0373fbd5ca.tar.bz2
Add the Optimize Compares pass (disabled by default).
This pass tries to remove comparison instructions when possible. For instance, if you have this code: sub r1, 1 cmp r1, 0 bz L1 and "sub" either sets the same flag as the "cmp" instruction or could be converted to set the same flag, then we can eliminate the "cmp" instruction all together. This is a important for ARM where the ALU instructions could set the CPSR flag, but need a special suffix ('s') to do so. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110423 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/CodeGen/Passes.h4
-rw-r--r--include/llvm/Target/TargetInstrInfo.h15
2 files changed, 19 insertions, 0 deletions
diff --git a/include/llvm/CodeGen/Passes.h b/include/llvm/CodeGen/Passes.h
index c881d74..0fcdf7a 100644
--- a/include/llvm/CodeGen/Passes.h
+++ b/include/llvm/CodeGen/Passes.h
@@ -180,6 +180,10 @@ namespace llvm {
/// to take advantage of opportunities created during DAG legalization.
FunctionPass *createOptimizePHIsPass();
+ /// createOptimizeCmpsPass - This pass performs redundant comparison removal
+ /// optimization.
+ FunctionPass *createOptimizeCmpsPass();
+
/// createStackSlotColoringPass - This pass performs stack slot coloring.
FunctionPass *createStackSlotColoringPass(bool);
diff --git a/include/llvm/Target/TargetInstrInfo.h b/include/llvm/Target/TargetInstrInfo.h
index d5fe33f..1c6ac1a 100644
--- a/include/llvm/Target/TargetInstrInfo.h
+++ b/include/llvm/Target/TargetInstrInfo.h
@@ -576,6 +576,21 @@ public:
/// register allocation.
virtual ScheduleHazardRecognizer*
CreateTargetPostRAHazardRecognizer(const InstrItineraryData&) const = 0;
+
+ /// isCompareInstr - If the machine instruction is a comparison instruction,
+ /// then return true. Also return the source register in SrcReg and the value
+ /// it compares against in CmpValue.
+ virtual bool isCompareInstr(const MachineInstr *MI,
+ unsigned &SrcReg, int &CmpValue) const {
+ return false;
+ }
+
+ /// convertToSetZeroFlag - Convert the instruction to set the zero flag so
+ /// that we can remove a "comparison with zero".
+ virtual bool convertToSetZeroFlag(MachineInstr *Instr,
+ MachineInstr *CmpInstr) const {
+ return false;
+ }
};
/// TargetInstrInfoImpl - This is the default implementation of