diff options
| author | Gabor Greif <ggreif@gmail.com> | 2010-09-14 09:23:22 +0000 |
|---|---|---|
| committer | Gabor Greif <ggreif@gmail.com> | 2010-09-14 09:23:22 +0000 |
| commit | d0cef1e2ef810417097c207dd7fe6039f73e8aa2 (patch) | |
| tree | 492878e58bfd491c845bbbceaee3b343129909d4 /llvm/lib | |
| parent | 5dbe800203da951cb099a8aa02259a35baf51600 (diff) | |
| download | bcm5719-llvm-d0cef1e2ef810417097c207dd7fe6039f73e8aa2.tar.gz bcm5719-llvm-d0cef1e2ef810417097c207dd7fe6039f73e8aa2.zip | |
Eliminate a 'tst' that immediately follows an 'and'
by morphing the 'and' to its recording form 'andS'.
This is basically a test commit into this area, to
see whether the bots like me. Several generalizations
can be applied and various avenues of code simplification
are open. I'll introduce those as I go.
I am aware of stylistic input from Bill Wendling, about
where put the analysis complexity, but I am positive
that we can move things around easily and will find a
satisfactory solution.
llvm-svn: 113839
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp b/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp index 39feec99890..05870b800c6 100644 --- a/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp +++ b/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp @@ -1372,6 +1372,19 @@ AnalyzeCompare(const MachineInstr *MI, unsigned &SrcReg, int &CmpValue) const { SrcReg = MI->getOperand(0).getReg(); CmpValue = MI->getOperand(1).getImm(); return true; + case ARM::TSTri: { + if (MI->getParent()->begin() == MachineBasicBlock::const_iterator(MI)) + return false; + const MachineInstr *AND = llvm::prior(MI); + if (AND->getOpcode() != ARM::ANDri) + return false; + if (MI->getOperand(0).getReg() == AND->getOperand(1).getReg() && + MI->getOperand(1).getImm() == AND->getOperand(2).getImm()) { + SrcReg = AND->getOperand(0).getReg(); + CmpValue = 0; + return true; + } + } } return false; @@ -1421,6 +1434,8 @@ OptimizeCompareInstr(MachineInstr *CmpInstr, unsigned SrcReg, int CmpValue, switch (MI->getOpcode()) { default: break; case ARM::ADDri: + case ARM::ANDri: + case ARM::t2ANDri: case ARM::SUBri: case ARM::t2ADDri: case ARM::t2SUBri: |

