Index: llvm/trunk/lib/Target/X86/X86InstrInfo.td =================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td @@ -1994,7 +1994,7 @@ defm XCHG : ATOMIC_SWAP<0x86, 0x87, "xchg", "atomic_swap">, NotMemoryFoldable; // Swap between registers. -let SchedRW = [WriteALU] in { +let SchedRW = [WriteXCHG] in { let Constraints = "$src1 = $dst1, $src2 = $dst2", hasSideEffects = 0 in { def XCHG8rr : I<0x86, MRMSrcReg, (outs GR8:$dst1, GR8:$dst2), (ins GR8:$src1, GR8:$src2), @@ -2027,7 +2027,7 @@ } // SchedRW let hasSideEffects = 0, Constraints = "$src1 = $dst1, $src2 = $dst2", - Defs = [EFLAGS], SchedRW = [WriteALU] in { + Defs = [EFLAGS], SchedRW = [WriteXCHG] in { def XADD8rr : I<0xC0, MRMDestReg, (outs GR8:$dst1, GR8:$dst2), (ins GR8:$src1, GR8:$src2), "xadd{b}\t{$src2, $src1|$src1, $src2}", []>, TB; Index: llvm/trunk/lib/Target/X86/X86SchedBroadwell.td =================================================================== --- llvm/trunk/lib/Target/X86/X86SchedBroadwell.td +++ llvm/trunk/lib/Target/X86/X86SchedBroadwell.td @@ -121,6 +121,7 @@ defm : X86WriteRes; defm : X86WriteRes; +defm : X86WriteRes; defm : BWWriteResPair; def : WriteRes { let Latency = 3; } // Integer multiplication, high part. @@ -759,15 +760,6 @@ def: InstRW<[BWWriteResGroup28], (instregex "VPBROADCASTBrr", "VPBROADCASTWrr")>; -def BWWriteResGroup30 : SchedWriteRes<[BWPort0156]> { - let Latency = 2; - let NumMicroOps = 3; - let ResourceCycles = [3]; -} -def: InstRW<[BWWriteResGroup30], (instrs XADD8rr, XADD16rr, XADD32rr, XADD64rr, - XCHG8rr, XCHG16rr, XCHG32rr, XCHG64rr, - XCHG16ar, XCHG32ar, XCHG64ar)>; - def BWWriteResGroup33 : SchedWriteRes<[BWPort5,BWPort0156]> { let Latency = 3; let NumMicroOps = 3; Index: llvm/trunk/lib/Target/X86/X86SchedHaswell.td =================================================================== --- llvm/trunk/lib/Target/X86/X86SchedHaswell.td +++ llvm/trunk/lib/Target/X86/X86SchedHaswell.td @@ -126,6 +126,7 @@ defm : X86WriteRes; defm : X86WriteRes; +defm : X86WriteRes; def : WriteRes { let Latency = 3; } @@ -1287,15 +1288,6 @@ "VPMOVSXWDYrm", "VPMOVZXWDYrm")>; -def HWWriteResGroup54 : SchedWriteRes<[HWPort0156]> { - let Latency = 2; - let NumMicroOps = 3; - let ResourceCycles = [3]; -} -def: InstRW<[HWWriteResGroup54], (instrs XADD8rr, XADD16rr, XADD32rr, XADD64rr, - XCHG8rr, XCHG16rr, XCHG32rr, XCHG64rr, - XCHG16ar, XCHG32ar, XCHG64ar)>; - def HWWriteResGroup57 : SchedWriteRes<[HWPort5,HWPort0156]> { let Latency = 3; let NumMicroOps = 3; Index: llvm/trunk/lib/Target/X86/X86SchedSandyBridge.td =================================================================== --- llvm/trunk/lib/Target/X86/X86SchedSandyBridge.td +++ llvm/trunk/lib/Target/X86/X86SchedSandyBridge.td @@ -111,6 +111,7 @@ defm : SBWriteResPair; defm : SBWriteResPair; defm : SBWriteResPair; +defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; @@ -661,15 +662,6 @@ "SHL(8|16|32|64)rCL", "SHR(8|16|32|64)rCL")>; -def SBWriteResGroup25 : SchedWriteRes<[SBPort015]> { - let Latency = 2; - let NumMicroOps = 3; - let ResourceCycles = [3]; -} -def: InstRW<[SBWriteResGroup25], (instrs XADD8rr, XADD16rr, XADD32rr, XADD64rr, - XCHG8rr, XCHG16rr, XCHG32rr, XCHG64rr, - XCHG16ar, XCHG32ar, XCHG64ar)>; - def SBWriteResGroup25_1 : SchedWriteRes<[SBPort23,SBPort015]> { let Latency = 7; let NumMicroOps = 3; Index: llvm/trunk/lib/Target/X86/X86SchedSkylakeClient.td =================================================================== --- llvm/trunk/lib/Target/X86/X86SchedSkylakeClient.td +++ llvm/trunk/lib/Target/X86/X86SchedSkylakeClient.td @@ -112,6 +112,7 @@ defm : X86WriteRes; defm : X86WriteRes; +defm : X86WriteRes; defm : SKLWriteResPair; defm : SKLWriteResPair; @@ -776,15 +777,6 @@ "SHL(8|16|32|64)rCL", "SHR(8|16|32|64)rCL")>; -def SKLWriteResGroup34 : SchedWriteRes<[SKLPort0156]> { - let Latency = 2; - let NumMicroOps = 3; - let ResourceCycles = [3]; -} -def: InstRW<[SKLWriteResGroup34], (instrs XADD8rr, XADD16rr, XADD32rr, XADD64rr, - XCHG8rr, XCHG16rr, XCHG32rr, XCHG64rr, - XCHG16ar, XCHG32ar, XCHG64ar)>; - def SKLWriteResGroup35 : SchedWriteRes<[SKLPort0,SKLPort5]> { let Latency = 3; let NumMicroOps = 3; Index: llvm/trunk/lib/Target/X86/X86SchedSkylakeServer.td =================================================================== --- llvm/trunk/lib/Target/X86/X86SchedSkylakeServer.td +++ llvm/trunk/lib/Target/X86/X86SchedSkylakeServer.td @@ -112,6 +112,7 @@ defm : X86WriteRes; defm : X86WriteRes; +defm : X86WriteRes; defm : SKXWriteResPair; defm : SKXWriteResPair; @@ -844,15 +845,6 @@ "SHL(8|16|32|64)rCL", "SHR(8|16|32|64)rCL")>; -def SKXWriteResGroup36 : SchedWriteRes<[SKXPort0156]> { - let Latency = 2; - let NumMicroOps = 3; - let ResourceCycles = [3]; -} -def: InstRW<[SKXWriteResGroup36], (instrs XADD8rr, XADD16rr, XADD32rr, XADD64rr, - XCHG8rr, XCHG16rr, XCHG32rr, XCHG64rr, - XCHG16ar, XCHG32ar, XCHG64ar)>; - def SKXWriteResGroup37 : SchedWriteRes<[SKXPort0,SKXPort5]> { let Latency = 3; let NumMicroOps = 3; Index: llvm/trunk/lib/Target/X86/X86Schedule.td =================================================================== --- llvm/trunk/lib/Target/X86/X86Schedule.td +++ llvm/trunk/lib/Target/X86/X86Schedule.td @@ -120,6 +120,7 @@ def WriteBSWAP32 : SchedWrite; // Byte Order (Endianness) 32-bit Swap. def WriteBSWAP64 : SchedWrite; // Byte Order (Endianness) 64-bit Swap. +def WriteXCHG : SchedWrite; // Compare+Exchange - TODO RMW support. // Integer division. defm WriteDiv8 : X86SchedWritePair; Index: llvm/trunk/lib/Target/X86/X86ScheduleAtom.td =================================================================== --- llvm/trunk/lib/Target/X86/X86ScheduleAtom.td +++ llvm/trunk/lib/Target/X86/X86ScheduleAtom.td @@ -81,6 +81,7 @@ defm : AtomWriteResPair; defm : AtomWriteResPair; +defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; @@ -565,8 +566,6 @@ SCASB, SCASL, SCASQ, SCASW)>; def : InstRW<[AtomWrite01_2], (instregex "BT(C|R|S)(16|32|64)mi8", "PUSH(CS|DS|ES|FS|GS|SS)(16|32|64)", - "XADD(8|16|32|64)rr", - "XCHG(8|16|32|64)(ar|rr)", "(ST|ISTT)_F(P)?(16|32|64)?(m|rr)", "MMX_P(ADD|SUB)Qirr", "MOV(S|Z)X16rr8", Index: llvm/trunk/lib/Target/X86/X86ScheduleBtVer2.td =================================================================== --- llvm/trunk/lib/Target/X86/X86ScheduleBtVer2.td +++ llvm/trunk/lib/Target/X86/X86ScheduleBtVer2.td @@ -170,6 +170,7 @@ defm : X86WriteRes; defm : X86WriteRes; +defm : X86WriteRes; defm : JWriteResIntPair; defm : JWriteResIntPair; Index: llvm/trunk/lib/Target/X86/X86ScheduleSLM.td =================================================================== --- llvm/trunk/lib/Target/X86/X86ScheduleSLM.td +++ llvm/trunk/lib/Target/X86/X86ScheduleSLM.td @@ -100,6 +100,7 @@ defm : X86WriteRes; defm : X86WriteRes; +defm : X86WriteRes; defm : SLMWriteResPair; Index: llvm/trunk/lib/Target/X86/X86ScheduleZnver1.td =================================================================== --- llvm/trunk/lib/Target/X86/X86ScheduleZnver1.td +++ llvm/trunk/lib/Target/X86/X86ScheduleZnver1.td @@ -182,6 +182,7 @@ defm : X86WriteRes; defm : X86WriteRes; +defm : X86WriteRes; defm : ZnWriteResPair; @@ -499,14 +500,6 @@ def : InstRW<[WriteLoad], (instregex "MOV(S|Z)X32rm(8|16)")>; // XCHG. -// r,r. -def ZnWriteXCHG : SchedWriteRes<[ZnALU]> { - let NumMicroOps = 2; - let ResourceCycles = [2]; -} - -def : InstRW<[ZnWriteXCHG], (instregex "XCHG(8|16|32|64)rr", "XCHG(16|32|64)ar")>; - // r,m. def ZnWriteXCHGrm : SchedWriteRes<[ZnAGU, ZnALU]> { let Latency = 5; @@ -807,6 +800,8 @@ def : InstRW<[WriteMicrocoded], (instregex "STOS(B|L|Q|W)")>; // XADD. +def ZnXADD : SchedWriteRes<[ZnALU]>; +def : InstRW<[ZnXADD], (instregex "XADD(8|16|32|64)rr")>; def : InstRW<[WriteMicrocoded], (instregex "XADD(8|16|32|64)rm")>; //=== Floating Point x87 Instructions ===//