[llvm] 1d73c2b - [X86] AMD Zen 3: same-reg AVX YMM VPXOR is a zero-cycle(!) dep-breaking zero-idiom

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Fri May 14 10:23:41 PDT 2021


Author: Roman Lebedev
Date: 2021-05-14T20:22:59+03:00
New Revision: 1d73c2b8cfa3418ac07f376afb1a30c397d69e49

URL: https://github.com/llvm/llvm-project/commit/1d73c2b8cfa3418ac07f376afb1a30c397d69e49
DIFF: https://github.com/llvm/llvm-project/commit/1d73c2b8cfa3418ac07f376afb1a30c397d69e49.diff

LOG: [X86] AMD Zen 3: same-reg AVX YMM VPXOR is a zero-cycle(!) dep-breaking zero-idiom

As confirmed by exegesis measurements, and ref docs.

Added: 
    

Modified: 
    llvm/lib/Target/X86/X86ScheduleZnver3.td
    llvm/test/tools/llvm-mca/X86/Znver3/zero-idioms-avx-ymm.s

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86ScheduleZnver3.td b/llvm/lib/Target/X86/X86ScheduleZnver3.td
index d6cd7d60edc8..9f62219a15d8 100644
--- a/llvm/lib/Target/X86/X86ScheduleZnver3.td
+++ b/llvm/lib/Target/X86/X86ScheduleZnver3.td
@@ -1552,6 +1552,12 @@ def Zn3WriteVZeroIdiomLogicX : SchedWriteVariant<[
 // NOTE: PXORrr is not zero-cycle!
 def : InstRW<[Zn3WriteVZeroIdiomLogicX], (instrs VPXORrr)>;
 
+def Zn3WriteVZeroIdiomLogicY : SchedWriteVariant<[
+    SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [Zn3WriteZeroLatency]>,
+    SchedVar<NoSchedPred,                          [WriteVecLogicY]>
+]>;
+def : InstRW<[Zn3WriteVZeroIdiomLogicY], (instrs VPXORYrr)>;
+
 def : IsZeroIdiomFunction<[
   // GPR Zero-idioms.
   DepBreakingClass<[ XOR32rr, XOR32rr_REV,
@@ -1580,8 +1586,14 @@ def : IsZeroIdiomFunction<[
   ], ZeroIdiomPredicate>,
 
   // AVX YMM Zero-idioms.
-  DepBreakingClass<[ VXORPSYrr, VXORPDYrr,
-                     VANDNPSYrr, VANDNPDYrr ], ZeroIdiomPredicate>,
+  DepBreakingClass<[
+    // fp variants.
+    VXORPSYrr, VXORPDYrr,
+    VANDNPSYrr, VANDNPDYrr,
+
+    // int variants.
+    VPXORYrr
+  ], ZeroIdiomPredicate>,
 ]>;
 
 def : IsDepBreakingFunction<[

diff  --git a/llvm/test/tools/llvm-mca/X86/Znver3/zero-idioms-avx-ymm.s b/llvm/test/tools/llvm-mca/X86/Znver3/zero-idioms-avx-ymm.s
index d9c3f6386400..447f8f48dff5 100644
--- a/llvm/test/tools/llvm-mca/X86/Znver3/zero-idioms-avx-ymm.s
+++ b/llvm/test/tools/llvm-mca/X86/Znver3/zero-idioms-avx-ymm.s
@@ -394,13 +394,13 @@ vpxor %ymm1, %ymm0, %ymm0
 
 # 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
@@ -411,17 +411,17 @@ vpxor %ymm1, %ymm0, %ymm0
 # CHECK-NEXT: [6]: HasSideEffects (U)
 
 # CHECK:      [1]    [2]    [3]    [4]    [5]    [6]    Instructions:
-# CHECK-NEXT:  1      1     0.25                        vpxor	%ymm0, %ymm0, %ymm0
+# CHECK-NEXT:  1      0     0.17                        vpxor	%ymm0, %ymm0, %ymm0
 # CHECK-NEXT:  1      1     0.25                        vpxor	%ymm1, %ymm0, %ymm0
 
 # 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
@@ -455,20 +455,20 @@ vpxor %ymm1, %ymm0, %ymm0
 
 # 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    -      -      -      -      -      -      -      -      -      -      -     vpxor	%ymm0, %ymm0, %ymm0
-# CHECK-NEXT:  -      -      -      -      -      -      -      -     0.50    -     0.50    -      -      -      -      -      -      -      -      -      -      -      -     vpxor	%ymm1, %ymm0, %ymm0
+# CHECK-NEXT:  -      -      -      -      -      -      -      -      -      -      -      -      -      -      -      -      -      -      -      -      -      -      -     vpxor	%ymm0, %ymm0, %ymm0
+# CHECK-NEXT:  -      -      -      -      -      -      -      -     0.25   0.25   0.25   0.25    -      -      -      -      -      -      -      -      -      -      -     vpxor	%ymm1, %ymm0, %ymm0
 
 # CHECK:      Timeline view:
-# CHECK-NEXT: Index     0123456
+# CHECK-NEXT: Index     0123
 
-# CHECK:      [0,0]     DeER ..   vpxor	%ymm0, %ymm0, %ymm0
-# CHECK-NEXT: [0,1]     D=eER..   vpxor	%ymm1, %ymm0, %ymm0
-# CHECK-NEXT: [1,0]     D==eER.   vpxor	%ymm0, %ymm0, %ymm0
-# CHECK-NEXT: [1,1]     D===eER   vpxor	%ymm1, %ymm0, %ymm0
+# CHECK:      [0,0]     DR .   vpxor	%ymm0, %ymm0, %ymm0
+# CHECK-NEXT: [0,1]     DeER   vpxor	%ymm1, %ymm0, %ymm0
+# CHECK-NEXT: [1,0]     D--R   vpxor	%ymm0, %ymm0, %ymm0
+# CHECK-NEXT: [1,1]     DeER   vpxor	%ymm1, %ymm0, %ymm0
 
 # CHECK:      Average Wait times (based on the timeline view):
 # CHECK-NEXT: [0]: Executions
@@ -477,6 +477,6 @@ vpxor %ymm1, %ymm0, %ymm0
 # 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       vpxor	%ymm0, %ymm0, %ymm0
-# CHECK-NEXT: 1.     2     3.0    0.0    0.0       vpxor	%ymm1, %ymm0, %ymm0
-# CHECK-NEXT:        2     2.5    0.3    0.0       <total>
+# CHECK-NEXT: 0.     2     0.0    0.0    1.0       vpxor	%ymm0, %ymm0, %ymm0
+# CHECK-NEXT: 1.     2     1.0    1.0    0.0       vpxor	%ymm1, %ymm0, %ymm0
+# CHECK-NEXT:        2     0.5    0.5    0.5       <total>


        


More information about the llvm-commits mailing list