[llvm-commits] [llvm] r114430 - /llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp
Gabor Greif
ggreif at gmail.com
Tue Sep 21 06:30:57 PDT 2010
Author: ggreif
Date: Tue Sep 21 08:30:57 2010
New Revision: 114430
URL: http://llvm.org/viewvc/llvm-project?rev=114430&view=rev
Log:
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.
Modified:
llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp
Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=114430&r1=114429&r2=114430&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Tue Sep 21 08:30:57 2010
@@ -1399,12 +1399,13 @@
}
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 @@
// 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;
More information about the llvm-commits
mailing list