From d334fd8763e7683fed0247809b350a4c341b8c24 Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Fri, 14 May 2021 16:19:31 +0300 Subject: [PATCH] [X86] AMD Zen 3: same-reg AVX XMM VPANDN is a zero-cycle(!) dep-breaking zero-idiom As confirmed by exegesis measurements, and ref docs. --- lib/Target/X86/X86ScheduleZnver3.td | 7 ++-- .../llvm-mca/X86/Znver3/zero-idioms-avx-xmm.s | 40 +++++++++---------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/lib/Target/X86/X86ScheduleZnver3.td b/lib/Target/X86/X86ScheduleZnver3.td index 956a7ba14c1..97aaccf2a9f 100644 --- a/lib/Target/X86/X86ScheduleZnver3.td +++ b/lib/Target/X86/X86ScheduleZnver3.td @@ -1549,8 +1549,8 @@ def Zn3WriteVZeroIdiomLogicX : SchedWriteVariant<[ SchedVar, [Zn3WriteZeroLatency]>, SchedVar ]>; -// NOTE: PXORrr is not zero-cycle! -def : InstRW<[Zn3WriteVZeroIdiomLogicX], (instrs VPXORrr)>; +// NOTE: PXORrr,PANDNrr are not zero-cycle! +def : InstRW<[Zn3WriteVZeroIdiomLogicX], (instrs VPXORrr, VPANDNrr)>; def Zn3WriteVZeroIdiomLogicY : SchedWriteVariant<[ SchedVar, [Zn3WriteZeroLatency]>, @@ -1583,7 +1583,8 @@ def : IsZeroIdiomFunction<[ VANDNPSrr, VANDNPDrr, // int variants. - VPXORrr + VPXORrr, + VPANDNrr ], ZeroIdiomPredicate>, // AVX YMM Zero-idioms. diff --git a/test/tools/llvm-mca/X86/Znver3/zero-idioms-avx-xmm.s b/test/tools/llvm-mca/X86/Znver3/zero-idioms-avx-xmm.s index 0d86cd7a618..35192f02564 100644 --- a/test/tools/llvm-mca/X86/Znver3/zero-idioms-avx-xmm.s +++ b/test/tools/llvm-mca/X86/Znver3/zero-idioms-avx-xmm.s @@ -490,13 +490,13 @@ vpandn %xmm1, %xmm0, %xmm0 # CHECK: Iterations: 10000 # CHECK-NEXT: Instructions: 20000 -# CHECK-NEXT: Total Cycles: 20003 +# CHECK-NEXT: Total Cycles: 3337 # CHECK-NEXT: Total uOps: 20000 # CHECK: Dispatch Width: 6 -# CHECK-NEXT: uOps Per Cycle: 1.00 -# CHECK-NEXT: IPC: 1.00 -# CHECK-NEXT: Block RThroughput: 0.5 +# CHECK-NEXT: uOps Per Cycle: 5.99 +# CHECK-NEXT: IPC: 5.99 +# CHECK-NEXT: Block RThroughput: 0.3 # CHECK: Instruction Info: # CHECK-NEXT: [1]: #uOps @@ -507,17 +507,17 @@ vpandn %xmm1, %xmm0, %xmm0 # CHECK-NEXT: [6]: HasSideEffects (U) # CHECK: [1] [2] [3] [4] [5] [6] Instructions: -# CHECK-NEXT: 1 1 0.25 vpandn %xmm0, %xmm0, %xmm0 +# CHECK-NEXT: 1 0 0.17 vpandn %xmm0, %xmm0, %xmm0 # CHECK-NEXT: 1 1 0.25 vpandn %xmm1, %xmm0, %xmm0 # CHECK: Register File statistics: -# CHECK-NEXT: Total number of mappings created: 20000 -# CHECK-NEXT: Max number of mappings used: 66 +# CHECK-NEXT: Total number of mappings created: 10000 +# CHECK-NEXT: Max number of mappings used: 9 # CHECK: * Register File #1 -- Zn3FpPRF: # CHECK-NEXT: Number of physical registers: 160 -# CHECK-NEXT: Total number of mappings created: 20000 -# CHECK-NEXT: Max number of mappings used: 66 +# CHECK-NEXT: Total number of mappings created: 10000 +# CHECK-NEXT: Max number of mappings used: 9 # CHECK: * Register File #2 -- Zn3IntegerPRF: # CHECK-NEXT: Number of physical registers: 192 @@ -551,20 +551,20 @@ vpandn %xmm1, %xmm0, %xmm0 # CHECK: Resource pressure per iteration: # CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12.0] [12.1] [13] [14.0] [14.1] [14.2] [15.0] [15.1] [15.2] [16.0] [16.1] -# CHECK-NEXT: - - - - - - - - 0.50 0.50 0.50 0.50 - - - - - - - - - - - +# CHECK-NEXT: - - - - - - - - 0.25 0.25 0.25 0.25 - - - - - - - - - - - # CHECK: Resource pressure by instruction: # CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12.0] [12.1] [13] [14.0] [14.1] [14.2] [15.0] [15.1] [15.2] [16.0] [16.1] Instructions: -# CHECK-NEXT: - - - - - - - - - 0.50 - 0.50 - - - - - - - - - - - vpandn %xmm0, %xmm0, %xmm0 -# CHECK-NEXT: - - - - - - - - 0.50 - 0.50 - - - - - - - - - - - - vpandn %xmm1, %xmm0, %xmm0 +# CHECK-NEXT: - - - - - - - - - - - - - - - - - - - - - - - vpandn %xmm0, %xmm0, %xmm0 +# CHECK-NEXT: - - - - - - - - 0.25 0.25 0.25 0.25 - - - - - - - - - - - vpandn %xmm1, %xmm0, %xmm0 # CHECK: Timeline view: -# CHECK-NEXT: Index 0123456 +# CHECK-NEXT: Index 0123 -# CHECK: [0,0] DeER .. vpandn %xmm0, %xmm0, %xmm0 -# CHECK-NEXT: [0,1] D=eER.. vpandn %xmm1, %xmm0, %xmm0 -# CHECK-NEXT: [1,0] D==eER. vpandn %xmm0, %xmm0, %xmm0 -# CHECK-NEXT: [1,1] D===eER vpandn %xmm1, %xmm0, %xmm0 +# CHECK: [0,0] DR . vpandn %xmm0, %xmm0, %xmm0 +# CHECK-NEXT: [0,1] DeER vpandn %xmm1, %xmm0, %xmm0 +# CHECK-NEXT: [1,0] D--R vpandn %xmm0, %xmm0, %xmm0 +# CHECK-NEXT: [1,1] DeER vpandn %xmm1, %xmm0, %xmm0 # CHECK: Average Wait times (based on the timeline view): # CHECK-NEXT: [0]: Executions @@ -573,6 +573,6 @@ vpandn %xmm1, %xmm0, %xmm0 # CHECK-NEXT: [3]: Average time elapsed from WB until retire stage # CHECK: [0] [1] [2] [3] -# CHECK-NEXT: 0. 2 2.0 0.5 0.0 vpandn %xmm0, %xmm0, %xmm0 -# CHECK-NEXT: 1. 2 3.0 0.0 0.0 vpandn %xmm1, %xmm0, %xmm0 -# CHECK-NEXT: 2 2.5 0.3 0.0 +# CHECK-NEXT: 0. 2 0.0 0.0 1.0 vpandn %xmm0, %xmm0, %xmm0 +# CHECK-NEXT: 1. 2 1.0 1.0 0.0 vpandn %xmm1, %xmm0, %xmm0 +# CHECK-NEXT: 2 0.5 0.5 0.5