[llvm] r325546 - [X86] Make a helper function for commuting AVX512 VPCMP immediates since we do it in two places.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 19 19:58:11 PST 2018
Author: ctopper
Date: Mon Feb 19 19:58:11 2018
New Revision: 325546
URL: http://llvm.org/viewvc/llvm-project?rev=325546&view=rev
Log:
[X86] Make a helper function for commuting AVX512 VPCMP immediates since we do it in two places.
Modified:
llvm/trunk/lib/Target/X86/X86InstrAVX512.td
llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
llvm/trunk/lib/Target/X86/X86InstrInfo.h
Modified: llvm/trunk/lib/Target/X86/X86InstrAVX512.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrAVX512.td?rev=325546&r1=325545&r2=325546&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrAVX512.td (original)
+++ llvm/trunk/lib/Target/X86/X86InstrAVX512.td Mon Feb 19 19:58:11 2018
@@ -2233,18 +2233,7 @@ defm VPCMPGTQ : avx512_icmp_packed_rmb_v
// operand.
def CommutePCMPCC : SDNodeXForm<imm, [{
uint8_t Imm = N->getZExtValue() & 0x7;
- switch (Imm) {
- default: llvm_unreachable("Unreachable!");
- case 0x01: Imm = 0x06; break; // LT -> NLE
- case 0x02: Imm = 0x05; break; // LE -> NLT
- case 0x05: Imm = 0x02; break; // NLT -> LE
- case 0x06: Imm = 0x01; break; // NLE -> LT
- case 0x00: // EQ
- case 0x03: // FALSE
- case 0x04: // NE
- case 0x07: // TRUE
- break;
- }
+ Imm = X86::getSwappedVPCMPImm(Imm);
return getI8Imm(Imm, SDLoc(N));
}]>;
Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=325546&r1=325545&r2=325546&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Mon Feb 19 19:58:11 2018
@@ -5399,18 +5399,7 @@ MachineInstr *X86InstrInfo::commuteInstr
case X86::VPCMPWZrrik: case X86::VPCMPUWZrrik: {
// Flip comparison mode immediate (if necessary).
unsigned Imm = MI.getOperand(MI.getNumOperands() - 1).getImm() & 0x7;
- switch (Imm) {
- default: llvm_unreachable("Unreachable!");
- case 0x01: Imm = 0x06; break; // LT -> NLE
- case 0x02: Imm = 0x05; break; // LE -> NLT
- case 0x05: Imm = 0x02; break; // NLT -> LE
- case 0x06: Imm = 0x01; break; // NLE -> LT
- case 0x00: // EQ
- case 0x03: // FALSE
- case 0x04: // NE
- case 0x07: // TRUE
- break;
- }
+ Imm = X86::getSwappedVPCMPImm(Imm);
auto &WorkingMI = cloneIfNew(MI);
WorkingMI.getOperand(MI.getNumOperands() - 1).setImm(Imm);
return TargetInstrInfo::commuteInstructionImpl(WorkingMI, /*NewMI=*/false,
@@ -6133,6 +6122,24 @@ unsigned X86::getCMovFromCond(CondCode C
}
}
+/// \brief Get the VPCMP immediate if the opcodes are swapped.
+unsigned X86::getSwappedVPCMPImm(unsigned Imm) {
+ switch (Imm) {
+ default: llvm_unreachable("Unreachable!");
+ case 0x01: Imm = 0x06; break; // LT -> NLE
+ case 0x02: Imm = 0x05; break; // LE -> NLT
+ case 0x05: Imm = 0x02; break; // NLT -> LE
+ case 0x06: Imm = 0x01; break; // NLE -> LT
+ case 0x00: // EQ
+ case 0x03: // FALSE
+ case 0x04: // NE
+ case 0x07: // TRUE
+ break;
+ }
+
+ return Imm;
+}
+
bool X86InstrInfo::isUnpredicatedTerminator(const MachineInstr &MI) const {
if (!MI.isTerminator()) return false;
Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.h?rev=325546&r1=325545&r2=325546&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.h (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.h Mon Feb 19 19:58:11 2018
@@ -83,6 +83,10 @@ CondCode getCondFromCMovOpc(unsigned Opc
/// GetOppositeBranchCondition - Return the inverse of the specified cond,
/// e.g. turning COND_E to COND_NE.
CondCode GetOppositeBranchCondition(CondCode CC);
+
+/// \brief Get the VPCMP immediate if the opcodes are swapped.
+unsigned getSwappedVPCMPImm(unsigned Imm);
+
} // namespace X86
/// isGlobalStubReference - Return true if the specified TargetFlag operand is
More information about the llvm-commits
mailing list