diff options
author | Gabor Greif <ggreif@gmail.com> | 2010-09-21 13:30:57 +0000 |
---|---|---|
committer | Gabor Greif <ggreif@gmail.com> | 2010-09-21 13:30:57 +0000 |
commit | 8ff9bb189ce188452e6cae6ed65cb2745814126c (patch) | |
tree | 393c0df1e31889483a2dafc6e15d57e8a0cc7fb4 | |
parent | e9c935662d77b8c5a3a26f5622dc2a3ed22d75c8 (diff) |
Fix buglet when the TST instruction directly uses the AND result.
I am unable to write a test for this case, help is solicited, though...
What I did is to tickle the code in the debugger and verify that we do the right thing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114430 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/ARM/ARMBaseInstrInfo.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/Target/ARM/ARMBaseInstrInfo.cpp b/lib/Target/ARM/ARMBaseInstrInfo.cpp index dfefa34e41..56f911a765 100644 --- a/lib/Target/ARM/ARMBaseInstrInfo.cpp +++ b/lib/Target/ARM/ARMBaseInstrInfo.cpp @@ -1399,12 +1399,13 @@ AnalyzeCompare(const MachineInstr *MI, unsigned &SrcReg, int &CmpMask, int &CmpV } static bool isSuitableForMask(const MachineInstr &MI, unsigned SrcReg, - int CmpMask) { + int CmpMask, bool CommonUse) { switch (MI.getOpcode()) { case ARM::ANDri: case ARM::t2ANDri: - if (SrcReg == MI.getOperand(1).getReg() && - CmpMask == MI.getOperand(2).getImm()) + if (CmpMask != MI.getOperand(2).getImm()) + return false; + if (SrcReg == MI.getOperand(CommonUse ? 1 : 0).getReg()) return true; break; } @@ -1431,13 +1432,13 @@ OptimizeCompareInstr(MachineInstr *CmpInstr, unsigned SrcReg, int CmpMask, // Masked compares sometimes use the same register as the corresponding 'and'. if (CmpMask != ~0) { - if (!isSuitableForMask(*MI, SrcReg, CmpMask)) { + if (!isSuitableForMask(*MI, SrcReg, CmpMask, false)) { MI = 0; for (MachineRegisterInfo::use_iterator UI = MRI.use_begin(SrcReg), UE = MRI.use_end(); UI != UE; ++UI) { if (UI->getParent() != CmpInstr->getParent()) continue; MachineInstr &PotentialAND = *UI; - if (!isSuitableForMask(PotentialAND, SrcReg, CmpMask)) + if (!isSuitableForMask(PotentialAND, SrcReg, CmpMask, true)) continue; SrcReg = PotentialAND.getOperand(0).getReg(); MI = &PotentialAND; |