Skip to content

Commit

Permalink
use range-for-loops; NFCI
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314676 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
rotateright committed Oct 2, 2017
1 parent 7b4a30a commit 84282c5
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions lib/CodeGen/TargetInstrInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,11 +522,9 @@ MachineInstr *TargetInstrInfo::foldMemoryOperand(MachineInstr &MI,
ArrayRef<unsigned> Ops, int FI,
LiveIntervals *LIS) const {
auto Flags = MachineMemOperand::MONone;
for (unsigned i = 0, e = Ops.size(); i != e; ++i)
if (MI.getOperand(Ops[i]).isDef())
Flags |= MachineMemOperand::MOStore;
else
Flags |= MachineMemOperand::MOLoad;
for (unsigned OpIdx : Ops)
Flags |= MI.getOperand(OpIdx).isDef() ? MachineMemOperand::MOStore
: MachineMemOperand::MOLoad;

MachineBasicBlock *MBB = MI.getParent();
assert(MBB && "foldMemoryOperand needs an inserted instruction");
Expand All @@ -542,10 +540,10 @@ MachineInstr *TargetInstrInfo::foldMemoryOperand(MachineInstr &MI,
if (Flags & MachineMemOperand::MOStore) {
MemSize = MFI.getObjectSize(FI);
} else {
for (unsigned Idx : Ops) {
for (unsigned OpIdx : Ops) {
int64_t OpSize = MFI.getObjectSize(FI);

if (auto SubReg = MI.getOperand(Idx).getSubReg()) {
if (auto SubReg = MI.getOperand(OpIdx).getSubReg()) {
unsigned SubRegSize = TRI->getSubRegIdxSize(SubReg);
if (SubRegSize > 0 && !(SubRegSize % 8))
OpSize = SubRegSize / 8;
Expand Down Expand Up @@ -613,9 +611,10 @@ MachineInstr *TargetInstrInfo::foldMemoryOperand(MachineInstr &MI,
LiveIntervals *LIS) const {
assert(LoadMI.canFoldAsLoad() && "LoadMI isn't foldable!");
#ifndef NDEBUG
for (unsigned i = 0, e = Ops.size(); i != e; ++i)
assert(MI.getOperand(Ops[i]).isUse() && "Folding load into def!");
for (unsigned OpIdx : Ops)
assert(MI.getOperand(OpIdx).isUse() && "Folding load into def!");
#endif

MachineBasicBlock &MBB = *MI.getParent();
MachineFunction &MF = *MBB.getParent();

Expand Down

0 comments on commit 84282c5

Please sign in to comment.