From 203876f104c6f45262c70ddf4c9b77ea2b9523c7 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Sun, 18 Mar 2018 19:54:42 +0000 Subject: [PATCH] [X86][Btver2] Fix crc32 schedule costs The default is currently FAdd for some reason llvm-svn: 327807 --- llvm/lib/Target/X86/X86ScheduleBtVer2.td | 16 ++++++++++++++++ llvm/test/CodeGen/X86/sse42-schedule.ll | 20 ++++++++++---------- .../tools/llvm-mca/X86/BtVer2/resources-sse42.s | 22 +++++++++++----------- 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/llvm/lib/Target/X86/X86ScheduleBtVer2.td b/llvm/lib/Target/X86/X86ScheduleBtVer2.td index b07258b..8811a5d 100644 --- a/llvm/lib/Target/X86/X86ScheduleBtVer2.td +++ b/llvm/lib/Target/X86/X86ScheduleBtVer2.td @@ -206,6 +206,22 @@ def JWriteIDiv32Ld : SchedWriteRes<[JLAGU, JALU1, JDiv]> { def : InstRW<[JWriteIDiv32], (instrs DIV32r, IDIV32r)>; def : InstRW<[JWriteIDiv32Ld], (instrs DIV32m, IDIV32m)>; +def JWriteCRC32 : SchedWriteRes<[JALU01]> { + let Latency = 3; + let ResourceCycles = [4]; + let NumMicroOps = 3; +} +def : InstRW<[JWriteCRC32], (instrs CRC32r32r8, CRC32r32r16, CRC32r32r32, + CRC32r64r8, CRC32r64r64)>; + +def JWriteCRC32Ld : SchedWriteRes<[JLAGU, JALU01]> { + let Latency = 6; + let ResourceCycles = [1, 4]; + let NumMicroOps = 3; +} +def : InstRW<[JWriteCRC32Ld], (instrs CRC32r32m8, CRC32r32m16, CRC32r32m32, + CRC32r64m8, CRC32r64m64)>; + //////////////////////////////////////////////////////////////////////////////// // Integer shifts and rotates. //////////////////////////////////////////////////////////////////////////////// diff --git a/llvm/test/CodeGen/X86/sse42-schedule.ll b/llvm/test/CodeGen/X86/sse42-schedule.ll index 26c72aa..bbf8acc 100644 --- a/llvm/test/CodeGen/X86/sse42-schedule.ll +++ b/llvm/test/CodeGen/X86/sse42-schedule.ll @@ -62,8 +62,8 @@ define i32 @crc32_32_8(i32 %a0, i8 %a1, i8 *%a2) { ; ; BTVER2-LABEL: crc32_32_8: ; BTVER2: # %bb.0: -; BTVER2-NEXT: crc32b %sil, %edi # sched: [3:1.00] -; BTVER2-NEXT: crc32b (%rdx), %edi # sched: [8:1.00] +; BTVER2-NEXT: crc32b %sil, %edi # sched: [3:2.00] +; BTVER2-NEXT: crc32b (%rdx), %edi # sched: [6:2.00] ; BTVER2-NEXT: movl %edi, %eax # sched: [1:0.50] ; BTVER2-NEXT: retq # sched: [4:1.00] ; @@ -132,8 +132,8 @@ define i32 @crc32_32_16(i32 %a0, i16 %a1, i16 *%a2) { ; ; BTVER2-LABEL: crc32_32_16: ; BTVER2: # %bb.0: -; BTVER2-NEXT: crc32w %si, %edi # sched: [3:1.00] -; BTVER2-NEXT: crc32w (%rdx), %edi # sched: [8:1.00] +; BTVER2-NEXT: crc32w %si, %edi # sched: [3:2.00] +; BTVER2-NEXT: crc32w (%rdx), %edi # sched: [6:2.00] ; BTVER2-NEXT: movl %edi, %eax # sched: [1:0.50] ; BTVER2-NEXT: retq # sched: [4:1.00] ; @@ -202,8 +202,8 @@ define i32 @crc32_32_32(i32 %a0, i32 %a1, i32 *%a2) { ; ; BTVER2-LABEL: crc32_32_32: ; BTVER2: # %bb.0: -; BTVER2-NEXT: crc32l %esi, %edi # sched: [3:1.00] -; BTVER2-NEXT: crc32l (%rdx), %edi # sched: [8:1.00] +; BTVER2-NEXT: crc32l %esi, %edi # sched: [3:2.00] +; BTVER2-NEXT: crc32l (%rdx), %edi # sched: [6:2.00] ; BTVER2-NEXT: movl %edi, %eax # sched: [1:0.50] ; BTVER2-NEXT: retq # sched: [4:1.00] ; @@ -272,8 +272,8 @@ define i64 @crc32_64_8(i64 %a0, i8 %a1, i8 *%a2) nounwind { ; ; BTVER2-LABEL: crc32_64_8: ; BTVER2: # %bb.0: -; BTVER2-NEXT: crc32b %sil, %edi # sched: [3:1.00] -; BTVER2-NEXT: crc32b (%rdx), %edi # sched: [8:1.00] +; BTVER2-NEXT: crc32b %sil, %edi # sched: [3:2.00] +; BTVER2-NEXT: crc32b (%rdx), %edi # sched: [6:2.00] ; BTVER2-NEXT: movq %rdi, %rax # sched: [1:0.50] ; BTVER2-NEXT: retq # sched: [4:1.00] ; @@ -342,8 +342,8 @@ define i64 @crc32_64_64(i64 %a0, i64 %a1, i64 *%a2) { ; ; BTVER2-LABEL: crc32_64_64: ; BTVER2: # %bb.0: -; BTVER2-NEXT: crc32q %rsi, %rdi # sched: [3:1.00] -; BTVER2-NEXT: crc32q (%rdx), %rdi # sched: [8:1.00] +; BTVER2-NEXT: crc32q %rsi, %rdi # sched: [3:2.00] +; BTVER2-NEXT: crc32q (%rdx), %rdi # sched: [6:2.00] ; BTVER2-NEXT: movq %rdi, %rax # sched: [1:0.50] ; BTVER2-NEXT: retq # sched: [4:1.00] ; diff --git a/llvm/test/tools/llvm-mca/X86/BtVer2/resources-sse42.s b/llvm/test/tools/llvm-mca/X86/BtVer2/resources-sse42.s index 22db02f..153377c 100644 --- a/llvm/test/tools/llvm-mca/X86/BtVer2/resources-sse42.s +++ b/llvm/test/tools/llvm-mca/X86/BtVer2/resources-sse42.s @@ -48,16 +48,16 @@ pcmpgtq (%rax), %xmm2 # CHECK: Resource pressure by instruction: # CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] Instructions: -# CHECK-NEXT: - - - 1.00 - 1.00 - - - - - - - - crc32b %al, %ecx -# CHECK-NEXT: - - - 1.00 - 1.00 - 1.00 - - - - - - crc32b (%rax), %ecx -# CHECK-NEXT: - - - 1.00 - 1.00 - - - - - - - - crc32l %eax, %ecx -# CHECK-NEXT: - - - 1.00 - 1.00 - 1.00 - - - - - - crc32l (%rax), %ecx -# CHECK-NEXT: - - - 1.00 - 1.00 - - - - - - - - crc32w %ax, %ecx -# CHECK-NEXT: - - - 1.00 - 1.00 - 1.00 - - - - - - crc32w (%rax), %ecx -# CHECK-NEXT: - - - 1.00 - 1.00 - - - - - - - - crc32b %al, %rcx -# CHECK-NEXT: - - - 1.00 - 1.00 - 1.00 - - - - - - crc32b (%rax), %rcx -# CHECK-NEXT: - - - 1.00 - 1.00 - - - - - - - - crc32q %rax, %rcx -# CHECK-NEXT: - - - 1.00 - 1.00 - 1.00 - - - - - - crc32q (%rax), %rcx +# CHECK-NEXT: - 4.00 - - - - - - - - - - - - crc32b %al, %ecx +# CHECK-NEXT: 4.00 - - - - - - 1.00 - - - - - - crc32b (%rax), %ecx +# CHECK-NEXT: - 4.00 - - - - - - - - - - - - crc32l %eax, %ecx +# CHECK-NEXT: 4.00 - - - - - - 1.00 - - - - - - crc32l (%rax), %ecx +# CHECK-NEXT: - 4.00 - - - - - - - - - - - - crc32w %ax, %ecx +# CHECK-NEXT: 4.00 - - - - - - 1.00 - - - - - - crc32w (%rax), %ecx +# CHECK-NEXT: - 4.00 - - - - - - - - - - - - crc32b %al, %rcx +# CHECK-NEXT: 4.00 - - - - - - 1.00 - - - - - - crc32b (%rax), %rcx +# CHECK-NEXT: - 4.00 - - - - - - - - - - - - crc32q %rax, %rcx +# CHECK-NEXT: 4.00 - - - - - - 1.00 - - - - - - crc32q (%rax), %rcx # CHECK-NEXT: - - - - - 5.00 10.00 5.00 - - - - - - pcmpestri $1, %xmm0, %xmm2 # CHECK-NEXT: - - - - - 5.00 10.00 6.00 - - - - - - pcmpestri $1, (%rax), %xmm2 # CHECK-NEXT: - - - - - 5.00 10.00 5.00 - - - - - - pcmpestrm $1, %xmm0, %xmm2 @@ -67,4 +67,4 @@ pcmpgtq (%rax), %xmm2 # CHECK-NEXT: - - - - - 2.00 2.00 - - - - - - - pcmpistrm $1, %xmm0, %xmm2 # CHECK-NEXT: - - - - - 2.00 2.00 1.00 - - - - - - pcmpistrm $1, (%rax), %xmm2 # CHECK-NEXT: - - - - - - 1.00 - - - - - 1.00 - pcmpgtq %xmm0, %xmm2 -# CHECK-NEXT: - - - - - 0.01 0.99 1.00 - - - 1.00 - - pcmpgtq (%rax), %xmm2 +# CHECK-NEXT: - - - - - 1.00 - 1.00 - - - 1.00 - - pcmpgtq (%rax), %xmm2 -- 2.7.4