diff options
author | Bill Wendling <isanbard@gmail.com> | 2007-12-17 23:07:56 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2007-12-17 23:07:56 +0000 |
commit | 627c00b663f881600b4af1ae135af6ee2cb19c1a (patch) | |
tree | bdcc9719949b741a19aeeb13027fdfe824c2b8fe /lib/Target/X86/X86InstrInfo.cpp | |
parent | f9b83fcf95e8a280d7b117af8858596fe5b10d94 (diff) |
Add "mayHaveSideEffects" and "neverHasSideEffects" flags to some instructions. I
based what flag to set on whether it was already marked as
"isRematerializable". If there was a further check to determine if it's "really"
rematerializable, then I marked it as "mayHaveSideEffects" and created a check
in the X86 back-end similar to the remat one.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45132 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/X86InstrInfo.cpp')
-rw-r--r-- | lib/Target/X86/X86InstrInfo.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/Target/X86/X86InstrInfo.cpp b/lib/Target/X86/X86InstrInfo.cpp index 9d5e637119..d6d146f2a5 100644 --- a/lib/Target/X86/X86InstrInfo.cpp +++ b/lib/Target/X86/X86InstrInfo.cpp @@ -144,6 +144,40 @@ bool X86InstrInfo::isReallyTriviallyReMaterializable(MachineInstr *MI) const { return true; } +/// isReallySideEffectFree - If the M_MAY_HAVE_SIDE_EFFECTS flag is set, this +/// method is called to determine if the specific instance of this instruction +/// has side effects. This is useful in cases of instructions, like loads, which +/// generally always have side effects. A load from a constant pool doesn't have +/// side effects, though. So we need to differentiate it from the general case. +bool X86InstrInfo::isReallySideEffectFree(MachineInstr *MI) const { + switch (MI->getOpcode()) { + default: break; + case X86::MOV8rm: + case X86::MOV16rm: + case X86::MOV16_rm: + case X86::MOV32rm: + case X86::MOV32_rm: + case X86::MOV64rm: + case X86::LD_Fp64m: + case X86::MOVSSrm: + case X86::MOVSDrm: + case X86::MOVAPSrm: + case X86::MOVAPDrm: + case X86::MMX_MOVD64rm: + case X86::MMX_MOVQ64rm: + // Loads from constant pools have no side effects + return MI->getOperand(1).isRegister() && MI->getOperand(2).isImmediate() && + MI->getOperand(3).isRegister() && MI->getOperand(4).isConstantPoolIndex() && + MI->getOperand(1).getReg() == 0 && + MI->getOperand(2).getImmedValue() == 1 && + MI->getOperand(3).getReg() == 0; + } + + // All other instances of these instructions are presumed to have side + // effects. + return false; +} + /// hasLiveCondCodeDef - True if MI has a condition code def, e.g. EFLAGS, that /// is not marked dead. static bool hasLiveCondCodeDef(MachineInstr *MI) { |