From 6128b86b1d4e1ef7a699406772a1b8f8e80b8eb7 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Wed, 26 May 2021 11:07:22 +0100 Subject: [PATCH] [X86][SLM] Fix vector PSHUFB + variable shift resource/throughputs Match whats documented in the Intel AOM (+Agner) - PSHUFB xmm is really slow, and mmx/xmm vector shifts are half rate. Noticed while working to get the cost tables to more closely match llvm-mca analysis, in this case for shifts and truncations. --- lib/Target/X86/X86ScheduleSLM.td | 11 ++-- test/tools/llvm-mca/X86/SLM/resources-mmx.s | 66 +++++++++---------- test/tools/llvm-mca/X86/SLM/resources-sse2.s | 66 +++++++++---------- test/tools/llvm-mca/X86/SLM/resources-ssse3.s | 10 +-- 4 files changed, 77 insertions(+), 76 deletions(-) diff --git a/lib/Target/X86/X86ScheduleSLM.td b/lib/Target/X86/X86ScheduleSLM.td index 190b52ef3f3..bbfd7b34cf2 100644 --- a/lib/Target/X86/X86ScheduleSLM.td +++ b/lib/Target/X86/X86ScheduleSLM.td @@ -321,9 +321,9 @@ def : WriteRes; def : WriteRes; def : WriteRes; -defm : SLMWriteResPair; -defm : SLMWriteResPair; -defm : SLMWriteResPair; +defm : SLMWriteResPair; +defm : SLMWriteResPair; +defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; @@ -354,8 +354,8 @@ defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; -defm : SLMWriteResPair; -defm : SLMWriteResPair; +defm : SLMWriteResPair; +defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; @@ -397,6 +397,7 @@ defm : SLMWriteResPair; // Packed Compare Explicit Length Strings, Return Mask defm : SLMWriteResPair; + // Packed Compare Implicit Length Strings, Return Index defm : SLMWriteResPair; diff --git a/test/tools/llvm-mca/X86/SLM/resources-mmx.s b/test/tools/llvm-mca/X86/SLM/resources-mmx.s index ac4d8622fa6..75ca5dc8b98 100644 --- a/test/tools/llvm-mca/X86/SLM/resources-mmx.s +++ b/test/tools/llvm-mca/X86/SLM/resources-mmx.s @@ -218,29 +218,29 @@ pxor (%rax), %mm2 # CHECK-NEXT: 1 1 0.50 por %mm0, %mm2 # CHECK-NEXT: 1 4 1.00 * por (%rax), %mm2 # CHECK-NEXT: 1 1 1.00 pslld $1, %mm2 -# CHECK-NEXT: 1 1 1.00 pslld %mm0, %mm2 -# CHECK-NEXT: 1 4 1.00 * pslld (%rax), %mm2 +# CHECK-NEXT: 2 2 2.00 pslld %mm0, %mm2 +# CHECK-NEXT: 2 5 2.00 * pslld (%rax), %mm2 # CHECK-NEXT: 1 1 1.00 psllq $1, %mm2 -# CHECK-NEXT: 1 1 1.00 psllq %mm0, %mm2 -# CHECK-NEXT: 1 4 1.00 * psllq (%rax), %mm2 +# CHECK-NEXT: 2 2 2.00 psllq %mm0, %mm2 +# CHECK-NEXT: 2 5 2.00 * psllq (%rax), %mm2 # CHECK-NEXT: 1 1 1.00 psllw $1, %mm2 -# CHECK-NEXT: 1 1 1.00 psllw %mm0, %mm2 -# CHECK-NEXT: 1 4 1.00 * psllw (%rax), %mm2 +# CHECK-NEXT: 2 2 2.00 psllw %mm0, %mm2 +# CHECK-NEXT: 2 5 2.00 * psllw (%rax), %mm2 # CHECK-NEXT: 1 1 1.00 psrad $1, %mm2 -# CHECK-NEXT: 1 1 1.00 psrad %mm0, %mm2 -# CHECK-NEXT: 1 4 1.00 * psrad (%rax), %mm2 +# CHECK-NEXT: 2 2 2.00 psrad %mm0, %mm2 +# CHECK-NEXT: 2 5 2.00 * psrad (%rax), %mm2 # CHECK-NEXT: 1 1 1.00 psraw $1, %mm2 -# CHECK-NEXT: 1 1 1.00 psraw %mm0, %mm2 -# CHECK-NEXT: 1 4 1.00 * psraw (%rax), %mm2 +# CHECK-NEXT: 2 2 2.00 psraw %mm0, %mm2 +# CHECK-NEXT: 2 5 2.00 * psraw (%rax), %mm2 # CHECK-NEXT: 1 1 1.00 psrld $1, %mm2 -# CHECK-NEXT: 1 1 1.00 psrld %mm0, %mm2 -# CHECK-NEXT: 1 4 1.00 * psrld (%rax), %mm2 +# CHECK-NEXT: 2 2 2.00 psrld %mm0, %mm2 +# CHECK-NEXT: 2 5 2.00 * psrld (%rax), %mm2 # CHECK-NEXT: 1 1 1.00 psrlq $1, %mm2 -# CHECK-NEXT: 1 1 1.00 psrlq %mm0, %mm2 -# CHECK-NEXT: 1 4 1.00 * psrlq (%rax), %mm2 +# CHECK-NEXT: 2 2 2.00 psrlq %mm0, %mm2 +# CHECK-NEXT: 2 5 2.00 * psrlq (%rax), %mm2 # CHECK-NEXT: 1 1 1.00 psrlw $1, %mm2 -# CHECK-NEXT: 1 1 1.00 psrlw %mm0, %mm2 -# CHECK-NEXT: 1 4 1.00 * psrlw (%rax), %mm2 +# CHECK-NEXT: 2 2 2.00 psrlw %mm0, %mm2 +# CHECK-NEXT: 2 5 2.00 * psrlw (%rax), %mm2 # CHECK-NEXT: 1 1 0.50 psubb %mm0, %mm2 # CHECK-NEXT: 1 4 1.00 * psubb (%rax), %mm2 # CHECK-NEXT: 1 1 0.50 psubd %mm0, %mm2 @@ -282,7 +282,7 @@ pxor (%rax), %mm2 # CHECK: Resource pressure per iteration: # CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] -# CHECK-NEXT: - - - 77.00 29.00 2.00 2.00 48.00 +# CHECK-NEXT: - - - 93.00 29.00 2.00 2.00 48.00 # CHECK: Resource pressure by instruction: # CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] Instructions: @@ -340,29 +340,29 @@ pxor (%rax), %mm2 # CHECK-NEXT: - - - 0.50 0.50 - - - por %mm0, %mm2 # CHECK-NEXT: - - - 0.50 0.50 - - 1.00 por (%rax), %mm2 # CHECK-NEXT: - - - 1.00 - - - - pslld $1, %mm2 -# CHECK-NEXT: - - - 1.00 - - - - pslld %mm0, %mm2 -# CHECK-NEXT: - - - 1.00 - - - 1.00 pslld (%rax), %mm2 +# CHECK-NEXT: - - - 2.00 - - - - pslld %mm0, %mm2 +# CHECK-NEXT: - - - 2.00 - - - 1.00 pslld (%rax), %mm2 # CHECK-NEXT: - - - 1.00 - - - - psllq $1, %mm2 -# CHECK-NEXT: - - - 1.00 - - - - psllq %mm0, %mm2 -# CHECK-NEXT: - - - 1.00 - - - 1.00 psllq (%rax), %mm2 +# CHECK-NEXT: - - - 2.00 - - - - psllq %mm0, %mm2 +# CHECK-NEXT: - - - 2.00 - - - 1.00 psllq (%rax), %mm2 # CHECK-NEXT: - - - 1.00 - - - - psllw $1, %mm2 -# CHECK-NEXT: - - - 1.00 - - - - psllw %mm0, %mm2 -# CHECK-NEXT: - - - 1.00 - - - 1.00 psllw (%rax), %mm2 +# CHECK-NEXT: - - - 2.00 - - - - psllw %mm0, %mm2 +# CHECK-NEXT: - - - 2.00 - - - 1.00 psllw (%rax), %mm2 # CHECK-NEXT: - - - 1.00 - - - - psrad $1, %mm2 -# CHECK-NEXT: - - - 1.00 - - - - psrad %mm0, %mm2 -# CHECK-NEXT: - - - 1.00 - - - 1.00 psrad (%rax), %mm2 +# CHECK-NEXT: - - - 2.00 - - - - psrad %mm0, %mm2 +# CHECK-NEXT: - - - 2.00 - - - 1.00 psrad (%rax), %mm2 # CHECK-NEXT: - - - 1.00 - - - - psraw $1, %mm2 -# CHECK-NEXT: - - - 1.00 - - - - psraw %mm0, %mm2 -# CHECK-NEXT: - - - 1.00 - - - 1.00 psraw (%rax), %mm2 +# CHECK-NEXT: - - - 2.00 - - - - psraw %mm0, %mm2 +# CHECK-NEXT: - - - 2.00 - - - 1.00 psraw (%rax), %mm2 # CHECK-NEXT: - - - 1.00 - - - - psrld $1, %mm2 -# CHECK-NEXT: - - - 1.00 - - - - psrld %mm0, %mm2 -# CHECK-NEXT: - - - 1.00 - - - 1.00 psrld (%rax), %mm2 +# CHECK-NEXT: - - - 2.00 - - - - psrld %mm0, %mm2 +# CHECK-NEXT: - - - 2.00 - - - 1.00 psrld (%rax), %mm2 # CHECK-NEXT: - - - 1.00 - - - - psrlq $1, %mm2 -# CHECK-NEXT: - - - 1.00 - - - - psrlq %mm0, %mm2 -# CHECK-NEXT: - - - 1.00 - - - 1.00 psrlq (%rax), %mm2 +# CHECK-NEXT: - - - 2.00 - - - - psrlq %mm0, %mm2 +# CHECK-NEXT: - - - 2.00 - - - 1.00 psrlq (%rax), %mm2 # CHECK-NEXT: - - - 1.00 - - - - psrlw $1, %mm2 -# CHECK-NEXT: - - - 1.00 - - - - psrlw %mm0, %mm2 -# CHECK-NEXT: - - - 1.00 - - - 1.00 psrlw (%rax), %mm2 +# CHECK-NEXT: - - - 2.00 - - - - psrlw %mm0, %mm2 +# CHECK-NEXT: - - - 2.00 - - - 1.00 psrlw (%rax), %mm2 # CHECK-NEXT: - - - 0.50 0.50 - - - psubb %mm0, %mm2 # CHECK-NEXT: - - - 0.50 0.50 - - 1.00 psubb (%rax), %mm2 # CHECK-NEXT: - - - 0.50 0.50 - - - psubd %mm0, %mm2 diff --git a/test/tools/llvm-mca/X86/SLM/resources-sse2.s b/test/tools/llvm-mca/X86/SLM/resources-sse2.s index 954c5cc2f51..7bcfd6b919b 100644 --- a/test/tools/llvm-mca/X86/SLM/resources-sse2.s +++ b/test/tools/llvm-mca/X86/SLM/resources-sse2.s @@ -595,31 +595,31 @@ xorpd (%rax), %xmm2 # CHECK-NEXT: 1 1 1.00 pshuflw $1, %xmm0, %xmm2 # CHECK-NEXT: 1 4 1.00 * pshuflw $1, (%rax), %xmm2 # CHECK-NEXT: 1 1 1.00 pslld $1, %xmm2 -# CHECK-NEXT: 1 1 1.00 pslld %xmm0, %xmm2 -# CHECK-NEXT: 1 4 1.00 * pslld (%rax), %xmm2 +# CHECK-NEXT: 2 2 2.00 pslld %xmm0, %xmm2 +# CHECK-NEXT: 2 5 2.00 * pslld (%rax), %xmm2 # CHECK-NEXT: 1 1 1.00 pslldq $1, %xmm2 # CHECK-NEXT: 1 1 1.00 psllq $1, %xmm2 -# CHECK-NEXT: 1 1 1.00 psllq %xmm0, %xmm2 -# CHECK-NEXT: 1 4 1.00 * psllq (%rax), %xmm2 +# CHECK-NEXT: 2 2 2.00 psllq %xmm0, %xmm2 +# CHECK-NEXT: 2 5 2.00 * psllq (%rax), %xmm2 # CHECK-NEXT: 1 1 1.00 psllw $1, %xmm2 -# CHECK-NEXT: 1 1 1.00 psllw %xmm0, %xmm2 -# CHECK-NEXT: 1 4 1.00 * psllw (%rax), %xmm2 +# CHECK-NEXT: 2 2 2.00 psllw %xmm0, %xmm2 +# CHECK-NEXT: 2 5 2.00 * psllw (%rax), %xmm2 # CHECK-NEXT: 1 1 1.00 psrad $1, %xmm2 -# CHECK-NEXT: 1 1 1.00 psrad %xmm0, %xmm2 -# CHECK-NEXT: 1 4 1.00 * psrad (%rax), %xmm2 +# CHECK-NEXT: 2 2 2.00 psrad %xmm0, %xmm2 +# CHECK-NEXT: 2 5 2.00 * psrad (%rax), %xmm2 # CHECK-NEXT: 1 1 1.00 psraw $1, %xmm2 -# CHECK-NEXT: 1 1 1.00 psraw %xmm0, %xmm2 -# CHECK-NEXT: 1 4 1.00 * psraw (%rax), %xmm2 +# CHECK-NEXT: 2 2 2.00 psraw %xmm0, %xmm2 +# CHECK-NEXT: 2 5 2.00 * psraw (%rax), %xmm2 # CHECK-NEXT: 1 1 1.00 psrld $1, %xmm2 -# CHECK-NEXT: 1 1 1.00 psrld %xmm0, %xmm2 -# CHECK-NEXT: 1 4 1.00 * psrld (%rax), %xmm2 +# CHECK-NEXT: 2 2 2.00 psrld %xmm0, %xmm2 +# CHECK-NEXT: 2 5 2.00 * psrld (%rax), %xmm2 # CHECK-NEXT: 1 1 1.00 psrldq $1, %xmm2 # CHECK-NEXT: 1 1 1.00 psrlq $1, %xmm2 -# CHECK-NEXT: 1 1 1.00 psrlq %xmm0, %xmm2 -# CHECK-NEXT: 1 4 1.00 * psrlq (%rax), %xmm2 +# CHECK-NEXT: 2 2 2.00 psrlq %xmm0, %xmm2 +# CHECK-NEXT: 2 5 2.00 * psrlq (%rax), %xmm2 # CHECK-NEXT: 1 1 1.00 psrlw $1, %xmm2 -# CHECK-NEXT: 1 1 1.00 psrlw %xmm0, %xmm2 -# CHECK-NEXT: 1 4 1.00 * psrlw (%rax), %xmm2 +# CHECK-NEXT: 2 2 2.00 psrlw %xmm0, %xmm2 +# CHECK-NEXT: 2 5 2.00 * psrlw (%rax), %xmm2 # CHECK-NEXT: 1 1 0.50 psubb %xmm0, %xmm2 # CHECK-NEXT: 1 4 1.00 * psubb (%rax), %xmm2 # CHECK-NEXT: 1 1 0.50 psubd %xmm0, %xmm2 @@ -687,7 +687,7 @@ xorpd (%rax), %xmm2 # CHECK: Resource pressure per iteration: # CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] -# CHECK-NEXT: - 412.00 12.00 158.50 96.50 3.00 3.00 134.00 +# CHECK-NEXT: - 412.00 12.00 174.50 96.50 3.00 3.00 134.00 # CHECK: Resource pressure by instruction: # CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] Instructions: @@ -879,31 +879,31 @@ xorpd (%rax), %xmm2 # CHECK-NEXT: - - - 1.00 - - - - pshuflw $1, %xmm0, %xmm2 # CHECK-NEXT: - - - 1.00 - - - 1.00 pshuflw $1, (%rax), %xmm2 # CHECK-NEXT: - - - 1.00 - - - - pslld $1, %xmm2 -# CHECK-NEXT: - - - 1.00 - - - - pslld %xmm0, %xmm2 -# CHECK-NEXT: - - - 1.00 - - - 1.00 pslld (%rax), %xmm2 +# CHECK-NEXT: - - - 2.00 - - - - pslld %xmm0, %xmm2 +# CHECK-NEXT: - - - 2.00 - - - 1.00 pslld (%rax), %xmm2 # CHECK-NEXT: - - - 1.00 - - - - pslldq $1, %xmm2 # CHECK-NEXT: - - - 1.00 - - - - psllq $1, %xmm2 -# CHECK-NEXT: - - - 1.00 - - - - psllq %xmm0, %xmm2 -# CHECK-NEXT: - - - 1.00 - - - 1.00 psllq (%rax), %xmm2 +# CHECK-NEXT: - - - 2.00 - - - - psllq %xmm0, %xmm2 +# CHECK-NEXT: - - - 2.00 - - - 1.00 psllq (%rax), %xmm2 # CHECK-NEXT: - - - 1.00 - - - - psllw $1, %xmm2 -# CHECK-NEXT: - - - 1.00 - - - - psllw %xmm0, %xmm2 -# CHECK-NEXT: - - - 1.00 - - - 1.00 psllw (%rax), %xmm2 +# CHECK-NEXT: - - - 2.00 - - - - psllw %xmm0, %xmm2 +# CHECK-NEXT: - - - 2.00 - - - 1.00 psllw (%rax), %xmm2 # CHECK-NEXT: - - - 1.00 - - - - psrad $1, %xmm2 -# CHECK-NEXT: - - - 1.00 - - - - psrad %xmm0, %xmm2 -# CHECK-NEXT: - - - 1.00 - - - 1.00 psrad (%rax), %xmm2 +# CHECK-NEXT: - - - 2.00 - - - - psrad %xmm0, %xmm2 +# CHECK-NEXT: - - - 2.00 - - - 1.00 psrad (%rax), %xmm2 # CHECK-NEXT: - - - 1.00 - - - - psraw $1, %xmm2 -# CHECK-NEXT: - - - 1.00 - - - - psraw %xmm0, %xmm2 -# CHECK-NEXT: - - - 1.00 - - - 1.00 psraw (%rax), %xmm2 +# CHECK-NEXT: - - - 2.00 - - - - psraw %xmm0, %xmm2 +# CHECK-NEXT: - - - 2.00 - - - 1.00 psraw (%rax), %xmm2 # CHECK-NEXT: - - - 1.00 - - - - psrld $1, %xmm2 -# CHECK-NEXT: - - - 1.00 - - - - psrld %xmm0, %xmm2 -# CHECK-NEXT: - - - 1.00 - - - 1.00 psrld (%rax), %xmm2 +# CHECK-NEXT: - - - 2.00 - - - - psrld %xmm0, %xmm2 +# CHECK-NEXT: - - - 2.00 - - - 1.00 psrld (%rax), %xmm2 # CHECK-NEXT: - - - 1.00 - - - - psrldq $1, %xmm2 # CHECK-NEXT: - - - 1.00 - - - - psrlq $1, %xmm2 -# CHECK-NEXT: - - - 1.00 - - - - psrlq %xmm0, %xmm2 -# CHECK-NEXT: - - - 1.00 - - - 1.00 psrlq (%rax), %xmm2 +# CHECK-NEXT: - - - 2.00 - - - - psrlq %xmm0, %xmm2 +# CHECK-NEXT: - - - 2.00 - - - 1.00 psrlq (%rax), %xmm2 # CHECK-NEXT: - - - 1.00 - - - - psrlw $1, %xmm2 -# CHECK-NEXT: - - - 1.00 - - - - psrlw %xmm0, %xmm2 -# CHECK-NEXT: - - - 1.00 - - - 1.00 psrlw (%rax), %xmm2 +# CHECK-NEXT: - - - 2.00 - - - - psrlw %xmm0, %xmm2 +# CHECK-NEXT: - - - 2.00 - - - 1.00 psrlw (%rax), %xmm2 # CHECK-NEXT: - - - 0.50 0.50 - - - psubb %xmm0, %xmm2 # CHECK-NEXT: - - - 0.50 0.50 - - 1.00 psubb (%rax), %xmm2 # CHECK-NEXT: - - - 0.50 0.50 - - - psubd %xmm0, %xmm2 diff --git a/test/tools/llvm-mca/X86/SLM/resources-ssse3.s b/test/tools/llvm-mca/X86/SLM/resources-ssse3.s index 6fcec27deb3..3084baecb2a 100644 --- a/test/tools/llvm-mca/X86/SLM/resources-ssse3.s +++ b/test/tools/llvm-mca/X86/SLM/resources-ssse3.s @@ -156,8 +156,8 @@ psignw (%rax), %xmm2 # CHECK-NEXT: 1 7 1.00 * pmulhrsw (%rax), %xmm2 # CHECK-NEXT: 1 1 1.00 pshufb %mm0, %mm2 # CHECK-NEXT: 1 4 1.00 * pshufb (%rax), %mm2 -# CHECK-NEXT: 1 1 1.00 pshufb %xmm0, %xmm2 -# CHECK-NEXT: 1 4 1.00 * pshufb (%rax), %xmm2 +# CHECK-NEXT: 4 5 5.00 pshufb %xmm0, %xmm2 +# CHECK-NEXT: 4 8 5.00 * pshufb (%rax), %xmm2 # CHECK-NEXT: 1 1 0.50 psignb %mm0, %mm2 # CHECK-NEXT: 1 4 1.00 * psignb (%rax), %mm2 # CHECK-NEXT: 1 1 0.50 psignb %xmm0, %xmm2 @@ -183,7 +183,7 @@ psignw (%rax), %xmm2 # CHECK: Resource pressure per iteration: # CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] -# CHECK-NEXT: - - - 40.00 24.00 - - 32.00 +# CHECK-NEXT: - - - 48.00 24.00 - - 32.00 # CHECK: Resource pressure by instruction: # CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] Instructions: @@ -237,8 +237,8 @@ psignw (%rax), %xmm2 # CHECK-NEXT: - - - 1.00 - - - 1.00 pmulhrsw (%rax), %xmm2 # CHECK-NEXT: - - - 1.00 - - - - pshufb %mm0, %mm2 # CHECK-NEXT: - - - 1.00 - - - 1.00 pshufb (%rax), %mm2 -# CHECK-NEXT: - - - 1.00 - - - - pshufb %xmm0, %xmm2 -# CHECK-NEXT: - - - 1.00 - - - 1.00 pshufb (%rax), %xmm2 +# CHECK-NEXT: - - - 5.00 - - - - pshufb %xmm0, %xmm2 +# CHECK-NEXT: - - - 5.00 - - - 1.00 pshufb (%rax), %xmm2 # CHECK-NEXT: - - - 0.50 0.50 - - - psignb %mm0, %mm2 # CHECK-NEXT: - - - 0.50 0.50 - - 1.00 psignb (%rax), %mm2 # CHECK-NEXT: - - - 0.50 0.50 - - - psignb %xmm0, %xmm2