Index: lib/Target/X86/X86InstrInfo.td =================================================================== --- lib/Target/X86/X86InstrInfo.td +++ lib/Target/X86/X86InstrInfo.td @@ -1352,7 +1352,7 @@ OpSize16, Requires<[Not64BitMode]>; } -let Constraints = "$src = $dst", SchedRW = [WriteALU] in { +let Constraints = "$src = $dst", SchedRW = [WriteBSWAP32] in { // This instruction is a consequence of BSWAP32r observing operand size. The // encoding is valid, but the behavior is undefined. let isCodeGenOnly = 1, ForceDisassemble = 1, hasSideEffects = 0 in @@ -1363,6 +1363,7 @@ "bswap{l}\t$dst", [(set GR32:$dst, (bswap GR32:$src))]>, OpSize32, TB; +let SchedRW = [WriteBSWAP64] in def BSWAP64r : RI<0xC8, AddRegFrm, (outs GR64:$dst), (ins GR64:$src), "bswap{q}\t$dst", [(set GR64:$dst, (bswap GR64:$src))]>, TB; Index: lib/Target/X86/X86SchedBroadwell.td =================================================================== --- lib/Target/X86/X86SchedBroadwell.td +++ lib/Target/X86/X86SchedBroadwell.td @@ -110,6 +110,8 @@ defm : BWWriteResPair; // Integer ALU + flags op. defm : BWWriteResPair; // Integer multiplication. defm : BWWriteResPair; // Integer 64-bit multiplication. +defm : BWWriteResPair; // +defm : BWWriteResPair; // defm : BWWriteResPair; defm : BWWriteResPair; @@ -699,20 +701,6 @@ } def: InstRW<[BWWriteResGroup18], (instrs SFENCE)>; -def BWWriteResGroup19 : SchedWriteRes<[BWPort06,BWPort15]> { - let Latency = 2; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[BWWriteResGroup19], (instrs BSWAP64r)>; - -def BWWriteResGroup19_1 : SchedWriteRes<[BWPort15]> { - let Latency = 1; - let NumMicroOps = 1; - let ResourceCycles = [1]; -} -def: InstRW<[BWWriteResGroup19_1], (instrs BSWAP32r)>; - def BWWriteResGroup20 : SchedWriteRes<[BWPort06,BWPort0156]> { let Latency = 2; let NumMicroOps = 2; Index: lib/Target/X86/X86SchedHaswell.td =================================================================== --- lib/Target/X86/X86SchedHaswell.td +++ lib/Target/X86/X86SchedHaswell.td @@ -119,6 +119,8 @@ def : WriteRes; defm : HWWriteResPair; +defm : HWWriteResPair; +defm : HWWriteResPair; defm : HWWriteResPair; defm : HWWriteResPair; defm : HWWriteResPair; @@ -1149,20 +1151,6 @@ } def: InstRW<[HWWriteResGroup33], (instregex "MMX_MOVDQ2Qrr")>; -def HWWriteResGroup34 : SchedWriteRes<[HWPort06,HWPort15]> { - let Latency = 2; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[HWWriteResGroup34], (instrs BSWAP64r)>; - -def HWWriteResGroup34_1 : SchedWriteRes<[HWPort15]> { - let Latency = 1; - let NumMicroOps = 1; - let ResourceCycles = [1]; -} -def: InstRW<[HWWriteResGroup34_1], (instrs BSWAP32r)>; - def HWWriteResGroup35 : SchedWriteRes<[HWPort06,HWPort0156]> { let Latency = 2; let NumMicroOps = 2; Index: lib/Target/X86/X86SchedSandyBridge.td =================================================================== --- lib/Target/X86/X86SchedSandyBridge.td +++ lib/Target/X86/X86SchedSandyBridge.td @@ -107,6 +107,8 @@ def : WriteRes; defm : SBWriteResPair; +defm : SBWriteResPair; +defm : SBWriteResPair; defm : SBWriteResPair; defm : SBWriteResPair; defm : SBWriteResPair; @@ -619,20 +621,6 @@ def: InstRW<[SBWriteResGroup15], (instrs CWD, FNSTSW16r)>; -def SBWriteResGroup16 : SchedWriteRes<[SBPort1,SBPort05]> { - let Latency = 2; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup16], (instrs BSWAP64r)>; - -def SBWriteResGroup16_1 : SchedWriteRes<[SBPort1]> { - let Latency = 1; - let NumMicroOps = 1; - let ResourceCycles = [1]; -} -def: InstRW<[SBWriteResGroup16_1], (instrs BSWAP32r)>; - def SBWriteResGroup18 : SchedWriteRes<[SBPort5,SBPort015]> { let Latency = 2; let NumMicroOps = 2; Index: lib/Target/X86/X86SchedSkylakeClient.td =================================================================== --- lib/Target/X86/X86SchedSkylakeClient.td +++ lib/Target/X86/X86SchedSkylakeClient.td @@ -109,6 +109,8 @@ defm : SKLWriteResPair; // Integer ALU + flags op. defm : SKLWriteResPair; // Integer multiplication. defm : SKLWriteResPair; // Integer 64-bit multiplication. +defm : SKLWriteResPair; // +defm : SKLWriteResPair; // defm : SKLWriteResPair; defm : SKLWriteResPair; @@ -698,20 +700,6 @@ } def: InstRW<[SKLWriteResGroup21], (instrs SFENCE)>; -def SKLWriteResGroup22 : SchedWriteRes<[SKLPort06,SKLPort15]> { - let Latency = 2; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SKLWriteResGroup22], (instrs BSWAP64r)>; - -def SKLWriteResGroup22_1 : SchedWriteRes<[SKLPort15]> { - let Latency = 1; - let NumMicroOps = 1; - let ResourceCycles = [1]; -} -def: InstRW<[SKLWriteResGroup22_1], (instrs BSWAP32r)>; - def SKLWriteResGroup23 : SchedWriteRes<[SKLPort06,SKLPort0156]> { let Latency = 2; let NumMicroOps = 2; Index: lib/Target/X86/X86SchedSkylakeServer.td =================================================================== --- lib/Target/X86/X86SchedSkylakeServer.td +++ lib/Target/X86/X86SchedSkylakeServer.td @@ -109,6 +109,8 @@ defm : SKXWriteResPair; // Integer ALU + flags op. defm : SKXWriteResPair; // Integer multiplication. defm : SKXWriteResPair; // Integer 64-bit multiplication. +defm : SKXWriteResPair; // +defm : SKXWriteResPair; // defm : SKXWriteResPair; defm : SKXWriteResPair; @@ -722,20 +724,6 @@ } def: InstRW<[SKXWriteResGroup21], (instrs SFENCE)>; -def SKXWriteResGroup22 : SchedWriteRes<[SKXPort06,SKXPort15]> { - let Latency = 2; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SKXWriteResGroup22], (instrs BSWAP64r)>; - -def SKXWriteResGroup22_1 : SchedWriteRes<[SKXPort15]> { - let Latency = 1; - let NumMicroOps = 1; - let ResourceCycles = [1]; -} -def: InstRW<[SKXWriteResGroup22_1], (instrs BSWAP32r)>; - def SKXWriteResGroup23 : SchedWriteRes<[SKXPort06,SKXPort0156]> { let Latency = 2; let NumMicroOps = 2; Index: lib/Target/X86/X86Schedule.td =================================================================== --- lib/Target/X86/X86Schedule.td +++ lib/Target/X86/X86Schedule.td @@ -117,6 +117,8 @@ defm WriteIMul64 : X86SchedWritePair; // Integer 64-bit multiplication. def WriteIMulH : SchedWrite; // Integer multiplication, high part. def WriteLEA : SchedWrite; // LEA instructions can't fold loads. +defm WriteBSWAP32: X86SchedWritePair; +defm WriteBSWAP64: X86SchedWritePair; // Integer division. defm WriteDiv8 : X86SchedWritePair; Index: lib/Target/X86/X86ScheduleAtom.td =================================================================== --- lib/Target/X86/X86ScheduleAtom.td +++ lib/Target/X86/X86ScheduleAtom.td @@ -80,6 +80,8 @@ defm : AtomWriteResPair; defm : AtomWriteResPair; defm : AtomWriteResPair; +defm : AtomWriteResPair; +defm : AtomWriteResPair; defm : AtomWriteResPair; defm : AtomWriteResPair; @@ -489,7 +491,6 @@ let ResourceCycles = [1]; } def : InstRW<[AtomWrite0_1], (instrs FXAM, LD_Frr, - BSWAP32r, BSWAP64r, MOVSX64rr32)>; def : SchedAlias; def : SchedAlias; Index: lib/Target/X86/X86ScheduleBtVer2.td =================================================================== --- lib/Target/X86/X86ScheduleBtVer2.td +++ lib/Target/X86/X86ScheduleBtVer2.td @@ -167,6 +167,8 @@ defm : JWriteResIntPair; // i8/i16/i32 multiplication defm : JWriteResIntPair; // i64 multiplication defm : X86WriteRes; +defm : JWriteResIntPair; +defm : JWriteResIntPair; defm : JWriteResIntPair; defm : JWriteResIntPair; Index: lib/Target/X86/X86ScheduleSLM.td =================================================================== --- lib/Target/X86/X86ScheduleSLM.td +++ lib/Target/X86/X86ScheduleSLM.td @@ -94,6 +94,8 @@ def : InstRW<[WriteMove], (instrs COPY)>; defm : SLMWriteResPair; +defm : SLMWriteResPair; +defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; Index: lib/Target/X86/X86ScheduleZnver1.td =================================================================== --- lib/Target/X86/X86ScheduleZnver1.td +++ lib/Target/X86/X86ScheduleZnver1.td @@ -176,6 +176,8 @@ def : WriteRes; def : WriteRes; defm : ZnWriteResPair; +defm : ZnWriteResPair; +defm : ZnWriteResPair; defm : ZnWriteResPair; defm : ZnWriteResPair; defm : ZnWriteResPair; @@ -537,12 +539,6 @@ //LAHF def : InstRW<[WriteMicrocoded], (instrs LAHF)>; -// BSWAP. -def ZnWriteBSwap : SchedWriteRes<[ZnALU]> { - let ResourceCycles = [4]; -} -def : InstRW<[ZnWriteBSwap], (instregex "BSWAP")>; - // MOVBE. // r,m. def ZnWriteMOVBE : SchedWriteRes<[ZnAGU, ZnALU]> {