diff options
author | Craig Topper <craig.topper@gmail.com> | 2011-11-15 06:39:01 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2011-11-15 06:39:01 +0000 |
commit | 44ec9fddc22abeabaf2565691ed02b1f47f532af (patch) | |
tree | 330a8f90816e68aad5c23ffd813a122efbb406ff | |
parent | f178418729d91e2f15a8eb27c0e4787b8ec7a3ce (diff) | |
download | external_llvm-44ec9fddc22abeabaf2565691ed02b1f47f532af.zip external_llvm-44ec9fddc22abeabaf2565691ed02b1f47f532af.tar.gz external_llvm-44ec9fddc22abeabaf2565691ed02b1f47f532af.tar.bz2 |
Fix PR11370 for real. Prevents converting 256-bit FP instruction to AVX2 256-bit integer instructions when AVX2 isn't enabled.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144629 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/X86/X86InstrInfo.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/lib/Target/X86/X86InstrInfo.cpp b/lib/Target/X86/X86InstrInfo.cpp index 9f7b21f..359a9df 100644 --- a/lib/Target/X86/X86InstrInfo.cpp +++ b/lib/Target/X86/X86InstrInfo.cpp @@ -3573,14 +3573,17 @@ static const unsigned ReplaceableInstrsAVX2[][3] = { // FIXME: Some shuffle and unpack instructions have equivalents in different // domains, but they require a bit more work than just switching opcodes. -static const unsigned *lookup(unsigned opcode, unsigned domain, bool hasAVX2) { +static const unsigned *lookup(unsigned opcode, unsigned domain) { for (unsigned i = 0, e = array_lengthof(ReplaceableInstrs); i != e; ++i) if (ReplaceableInstrs[i][domain-1] == opcode) return ReplaceableInstrs[i]; - if (domain != 3 || hasAVX2) // only use PackedInt domain if AVX2 is enabled - for (unsigned i = 0, e = array_lengthof(ReplaceableInstrsAVX2); i != e; ++i) - if (ReplaceableInstrsAVX2[i][domain-1] == opcode) - return ReplaceableInstrsAVX2[i]; + return 0; +} + +static const unsigned *lookupAVX2(unsigned opcode, unsigned domain) { + for (unsigned i = 0, e = array_lengthof(ReplaceableInstrsAVX2); i != e; ++i) + if (ReplaceableInstrsAVX2[i][domain-1] == opcode) + return ReplaceableInstrsAVX2[i]; return 0; } @@ -3588,16 +3591,21 @@ std::pair<uint16_t, uint16_t> X86InstrInfo::getExecutionDomain(const MachineInstr *MI) const { uint16_t domain = (MI->getDesc().TSFlags >> X86II::SSEDomainShift) & 3; bool hasAVX2 = TM.getSubtarget<X86Subtarget>().hasAVX2(); - return std::make_pair(domain, - domain && lookup(MI->getOpcode(), domain, hasAVX2) ? 0xe : 0); + uint16_t validDomains = 0; + if (domain && lookup(MI->getOpcode(), domain)) + validDomains = 0xe; + else if (domain && lookupAVX2(MI->getOpcode(), domain)) + validDomains = hasAVX2 ? 0xe : 0x6; + return std::make_pair(domain, validDomains); } void X86InstrInfo::setExecutionDomain(MachineInstr *MI, unsigned Domain) const { assert(Domain>0 && Domain<4 && "Invalid execution domain"); uint16_t dom = (MI->getDesc().TSFlags >> X86II::SSEDomainShift) & 3; assert(dom && "Not an SSE instruction"); - bool hasAVX2 = TM.getSubtarget<X86Subtarget>().hasAVX2(); - const unsigned *table = lookup(MI->getOpcode(), dom, hasAVX2); + const unsigned *table = lookup(MI->getOpcode(), dom); + if (!table) // try the other table + table = lookupAVX2(MI->getOpcode(), dom); assert(table && "Cannot change domain"); MI->setDesc(get(table[Domain-1])); } |