diff options
author | Evan Cheng <evan.cheng@apple.com> | 2008-03-31 07:54:19 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2008-03-31 07:54:19 +0000 |
commit | 9d15abe8385d17aa86c8144c8bbbac958fb91f17 (patch) | |
tree | 10b3db1522c2aad7321a12f8dc9ec9a0b87d94db /lib/Target/X86/X86InstrInfo.cpp | |
parent | 24d2f8a212f08bf21360122cc00acf2657af91f9 (diff) | |
download | external_llvm-9d15abe8385d17aa86c8144c8bbbac958fb91f17.zip external_llvm-9d15abe8385d17aa86c8144c8bbbac958fb91f17.tar.gz external_llvm-9d15abe8385d17aa86c8144c8bbbac958fb91f17.tar.bz2 |
Re-apply 48911.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48977 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/X86InstrInfo.cpp')
-rw-r--r-- | lib/Target/X86/X86InstrInfo.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/Target/X86/X86InstrInfo.cpp b/lib/Target/X86/X86InstrInfo.cpp index baa41f9..6c82f1c 100644 --- a/lib/Target/X86/X86InstrInfo.cpp +++ b/lib/Target/X86/X86InstrInfo.cpp @@ -748,6 +748,12 @@ static bool regIsPICBase(unsigned BaseReg, MachineRegisterInfo &MRI) { } return isPICBase; } + +/// isGVStub - Return true if the GV requires an extra load to get the +/// real address. +static inline bool isGVStub(GlobalValue *GV, X86TargetMachine &TM) { + return TM.getSubtarget<X86Subtarget>().GVRequiresExtraLoad(GV, TM, false); +} bool X86InstrInfo::isReallyTriviallyReMaterializable(MachineInstr *MI) const { switch (MI->getOpcode()) { @@ -769,7 +775,9 @@ bool X86InstrInfo::isReallyTriviallyReMaterializable(MachineInstr *MI) const { if (MI->getOperand(1).isReg() && MI->getOperand(2).isImm() && MI->getOperand(3).isReg() && MI->getOperand(3).getReg() == 0 && - MI->getOperand(4).isCPI()) { + (MI->getOperand(4).isCPI() || + (MI->getOperand(4).isGlobal() && + isGVStub(MI->getOperand(4).getGlobal(), TM)))) { unsigned BaseReg = MI->getOperand(1).getReg(); if (BaseReg == 0) return true; @@ -831,13 +839,9 @@ bool X86InstrInfo::isInvariantLoad(MachineInstr *MI) const { // Loads from constant pools are trivially invariant. if (MO.isCPI()) return true; - - if (MO.isGlobal()) { - if (TM.getSubtarget<X86Subtarget>().GVRequiresExtraLoad(MO.getGlobal(), - TM, false)) - return true; - return false; - } + + if (MO.isGlobal()) + return isGVStub(MO.getGlobal(), TM); // If this is a load from an invariant stack slot, the load is a constant. if (MO.isFI()) { |