aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/CodeGen/MachineInstr.h7
-rw-r--r--lib/Target/X86/X86InstrInfo.cpp10
2 files changed, 10 insertions, 7 deletions
diff --git a/include/llvm/CodeGen/MachineInstr.h b/include/llvm/CodeGen/MachineInstr.h
index 88116d2bb2..31f4974699 100644
--- a/include/llvm/CodeGen/MachineInstr.h
+++ b/include/llvm/CodeGen/MachineInstr.h
@@ -115,6 +115,13 @@ public:
{ return MemOperands.end(); }
bool memoperands_empty() const { return MemOperands.empty(); }
+ /// hasOneMemOperand - Return true if this instruction has exactly one
+ /// MachineMemOperand.
+ bool hasOneMemOperand() const {
+ return !memoperands_empty() &&
+ next(memoperands_begin()) == memoperands_end();
+ }
+
/// isIdenticalTo - Return true if this instruction is identical to (same
/// opcode and same operands as) the specified instruction.
bool isIdenticalTo(const MachineInstr *Other) const {
diff --git a/lib/Target/X86/X86InstrInfo.cpp b/lib/Target/X86/X86InstrInfo.cpp
index 7822ed7cb3..2f191ffa4b 100644
--- a/lib/Target/X86/X86InstrInfo.cpp
+++ b/lib/Target/X86/X86InstrInfo.cpp
@@ -2030,14 +2030,10 @@ MachineInstr* X86InstrInfo::foldMemoryOperand(MachineFunction &MF,
// Check switch flag
if (NoFusing) return NULL;
+ // Determine the alignment of the load.
unsigned Alignment = 0;
- for (alist<MachineMemOperand>::iterator i = LoadMI->memoperands_begin(),
- e = LoadMI->memoperands_end(); i != e; ++i) {
- const MachineMemOperand &MRO = *i;
- unsigned Align = MRO.getAlignment();
- if (Align > Alignment)
- Alignment = Align;
- }
+ if (LoadMI->hasOneMemOperand())
+ Alignment = LoadMI->memoperands_begin()->getAlignment();
// FIXME: Move alignment requirement into tables?
if (Alignment < 16) {