[llvm] ed37234 - [X86] Fix BMI uop/throughputs on znver1/znver2
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 17 12:38:48 PST 2022
Author: Simon Pilgrim
Date: 2022-12-17T20:38:40Z
New Revision: ed37234f9be3a257f360c7d1fc33a0391e0be288
URL: https://github.com/llvm/llvm-project/commit/ed37234f9be3a257f360c7d1fc33a0391e0be288
DIFF: https://github.com/llvm/llvm-project/commit/ed37234f9be3a257f360c7d1fc33a0391e0be288.diff
LOG: [X86] Fix BMI uop/throughputs on znver1/znver2
Most BMI ops are 2uop and 0.5 throughput - interestingly TZCNTrm doesn't take an extra uop but the other instructions do
Confirmed by AMD SoG + Agner
Added:
Modified:
llvm/lib/Target/X86/X86ScheduleZnver1.td
llvm/lib/Target/X86/X86ScheduleZnver2.td
llvm/test/tools/llvm-mca/X86/Znver1/resources-bmi1.s
llvm/test/tools/llvm-mca/X86/Znver2/resources-bmi1.s
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86ScheduleZnver1.td b/llvm/lib/Target/X86/X86ScheduleZnver1.td
index 3b2272f54ec2..d5cce17de12b 100644
--- a/llvm/lib/Target/X86/X86ScheduleZnver1.td
+++ b/llvm/lib/Target/X86/X86ScheduleZnver1.td
@@ -223,15 +223,15 @@ defm : X86WriteRes<WriteBitTestSet, [ZnALU], 2, [1], 2>;
defm : ZnWriteResPair<WriteBSF, [ZnALU], 3, [12], 6, 4, 2>;
defm : ZnWriteResPair<WriteBSR, [ZnALU], 4, [16], 6, 4, 2>;
defm : ZnWriteResPair<WriteLZCNT, [ZnALU], 2>;
-defm : ZnWriteResPair<WriteTZCNT, [ZnALU], 2>;
+defm : ZnWriteResPair<WriteTZCNT, [ZnALU], 2, [2], 2, 4, 0>;
defm : ZnWriteResPair<WritePOPCNT, [ZnALU], 1>;
// Treat misc copies as a move.
def : InstRW<[WriteMove], (instrs COPY)>;
// BMI1 BEXTR, BMI2 BZHI
-defm : ZnWriteResPair<WriteBEXTR, [ZnALU], 1>;
-defm : ZnWriteResPair<WriteBLS, [ZnALU], 2, [1], 2, 4, 1>;
+defm : ZnWriteResPair<WriteBEXTR, [ZnALU], 1, [1], 1, 4, 1>;
+defm : ZnWriteResPair<WriteBLS, [ZnALU], 2, [2], 2, 4, 1>;
defm : ZnWriteResPair<WriteBZHI, [ZnALU], 1>;
// IDIV
@@ -553,7 +553,7 @@ def ZnWritePUSH : SchedWriteRes<[ZnAGU]>{
}
def : InstRW<[ZnWritePUSH], (instregex "PUSH(16|32)rmm")>;
-//PUSHF
+// PUSHF
def : InstRW<[WriteMicrocoded], (instregex "PUSHF(16|32)")>;
// PUSHA.
diff --git a/llvm/lib/Target/X86/X86ScheduleZnver2.td b/llvm/lib/Target/X86/X86ScheduleZnver2.td
index 0ff4ba38ab78..b6c29eebeb79 100644
--- a/llvm/lib/Target/X86/X86ScheduleZnver2.td
+++ b/llvm/lib/Target/X86/X86ScheduleZnver2.td
@@ -222,15 +222,15 @@ defm : X86WriteRes<WriteBitTestSet, [Zn2ALU], 2, [1], 2>;
defm : Zn2WriteResPair<WriteBSF, [Zn2ALU], 3, [12], 6, 4, 2>;
defm : Zn2WriteResPair<WriteBSR, [Zn2ALU], 4, [16], 6, 4, 2>;
defm : Zn2WriteResPair<WriteLZCNT, [Zn2ALU], 1>;
-defm : Zn2WriteResPair<WriteTZCNT, [Zn2ALU], 2>;
+defm : Zn2WriteResPair<WriteTZCNT, [Zn2ALU], 2, [2], 2, 4, 0>;
defm : Zn2WriteResPair<WritePOPCNT, [Zn2ALU], 1>;
// Treat misc copies as a move.
def : InstRW<[WriteMove], (instrs COPY)>;
// BMI1 BEXTR, BMI2 BZHI
-defm : Zn2WriteResPair<WriteBEXTR, [Zn2ALU], 1>;
-defm : Zn2WriteResPair<WriteBLS, [Zn2ALU], 2, [1], 2, 4, 1>;
+defm : Zn2WriteResPair<WriteBEXTR, [Zn2ALU], 1, [1], 1, 4, 1>;
+defm : Zn2WriteResPair<WriteBLS, [Zn2ALU], 2, [2], 2, 4, 1>;
defm : Zn2WriteResPair<WriteBZHI, [Zn2ALU], 1>;
// IDIV
@@ -559,7 +559,7 @@ def Zn2WritePUSH : SchedWriteRes<[Zn2AGU]>{
}
def : InstRW<[Zn2WritePUSH], (instregex "PUSH(16|32)rmm")>;
-//PUSHF
+// PUSHF
def : InstRW<[WriteMicrocoded], (instregex "PUSHF(16|32)")>;
// PUSHA.
diff --git a/llvm/test/tools/llvm-mca/X86/Znver1/resources-bmi1.s b/llvm/test/tools/llvm-mca/X86/Znver1/resources-bmi1.s
index 542140fa2fa8..f9b174623bd3 100644
--- a/llvm/test/tools/llvm-mca/X86/Znver1/resources-bmi1.s
+++ b/llvm/test/tools/llvm-mca/X86/Znver1/resources-bmi1.s
@@ -57,23 +57,23 @@ tzcnt (%rax), %rcx
# CHECK-NEXT: 2 5 0.50 * bextrl %eax, (%rbx), %ecx
# CHECK-NEXT: 1 1 0.25 bextrq %rax, %rbx, %rcx
# CHECK-NEXT: 2 5 0.50 * bextrq %rax, (%rbx), %rcx
-# CHECK-NEXT: 2 2 0.25 blsil %eax, %ecx
+# CHECK-NEXT: 2 2 0.50 blsil %eax, %ecx
# CHECK-NEXT: 3 6 0.50 * blsil (%rax), %ecx
-# CHECK-NEXT: 2 2 0.25 blsiq %rax, %rcx
+# CHECK-NEXT: 2 2 0.50 blsiq %rax, %rcx
# CHECK-NEXT: 3 6 0.50 * blsiq (%rax), %rcx
-# CHECK-NEXT: 2 2 0.25 blsmskl %eax, %ecx
+# CHECK-NEXT: 2 2 0.50 blsmskl %eax, %ecx
# CHECK-NEXT: 3 6 0.50 * blsmskl (%rax), %ecx
-# CHECK-NEXT: 2 2 0.25 blsmskq %rax, %rcx
+# CHECK-NEXT: 2 2 0.50 blsmskq %rax, %rcx
# CHECK-NEXT: 3 6 0.50 * blsmskq (%rax), %rcx
-# CHECK-NEXT: 2 2 0.25 blsrl %eax, %ecx
+# CHECK-NEXT: 2 2 0.50 blsrl %eax, %ecx
# CHECK-NEXT: 3 6 0.50 * blsrl (%rax), %ecx
-# CHECK-NEXT: 2 2 0.25 blsrq %rax, %rcx
+# CHECK-NEXT: 2 2 0.50 blsrq %rax, %rcx
# CHECK-NEXT: 3 6 0.50 * blsrq (%rax), %rcx
-# CHECK-NEXT: 1 2 0.25 tzcntw %ax, %cx
+# CHECK-NEXT: 2 2 0.50 tzcntw %ax, %cx
# CHECK-NEXT: 2 6 0.50 * tzcntw (%rax), %cx
-# CHECK-NEXT: 1 2 0.25 tzcntl %eax, %ecx
+# CHECK-NEXT: 2 2 0.50 tzcntl %eax, %ecx
# CHECK-NEXT: 2 6 0.50 * tzcntl (%rax), %ecx
-# CHECK-NEXT: 1 2 0.25 tzcntq %rax, %rcx
+# CHECK-NEXT: 2 2 0.50 tzcntq %rax, %rcx
# CHECK-NEXT: 2 6 0.50 * tzcntq (%rax), %rcx
# CHECK: Resources:
@@ -92,7 +92,7 @@ tzcnt (%rax), %rcx
# CHECK: Resource pressure per iteration:
# CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]
-# CHECK-NEXT: 6.50 6.50 6.50 6.50 6.50 6.50 - - - - - -
+# CHECK-NEXT: 6.50 6.50 11.00 11.00 11.00 11.00 - - - - - -
# CHECK: Resource pressure by instruction:
# CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] Instructions:
@@ -104,21 +104,21 @@ tzcnt (%rax), %rcx
# CHECK-NEXT: 0.50 0.50 0.25 0.25 0.25 0.25 - - - - - - bextrl %eax, (%rbx), %ecx
# CHECK-NEXT: - - 0.25 0.25 0.25 0.25 - - - - - - bextrq %rax, %rbx, %rcx
# CHECK-NEXT: 0.50 0.50 0.25 0.25 0.25 0.25 - - - - - - bextrq %rax, (%rbx), %rcx
-# CHECK-NEXT: - - 0.25 0.25 0.25 0.25 - - - - - - blsil %eax, %ecx
-# CHECK-NEXT: 0.50 0.50 0.25 0.25 0.25 0.25 - - - - - - blsil (%rax), %ecx
-# CHECK-NEXT: - - 0.25 0.25 0.25 0.25 - - - - - - blsiq %rax, %rcx
-# CHECK-NEXT: 0.50 0.50 0.25 0.25 0.25 0.25 - - - - - - blsiq (%rax), %rcx
-# CHECK-NEXT: - - 0.25 0.25 0.25 0.25 - - - - - - blsmskl %eax, %ecx
-# CHECK-NEXT: 0.50 0.50 0.25 0.25 0.25 0.25 - - - - - - blsmskl (%rax), %ecx
-# CHECK-NEXT: - - 0.25 0.25 0.25 0.25 - - - - - - blsmskq %rax, %rcx
-# CHECK-NEXT: 0.50 0.50 0.25 0.25 0.25 0.25 - - - - - - blsmskq (%rax), %rcx
-# CHECK-NEXT: - - 0.25 0.25 0.25 0.25 - - - - - - blsrl %eax, %ecx
-# CHECK-NEXT: 0.50 0.50 0.25 0.25 0.25 0.25 - - - - - - blsrl (%rax), %ecx
-# CHECK-NEXT: - - 0.25 0.25 0.25 0.25 - - - - - - blsrq %rax, %rcx
-# CHECK-NEXT: 0.50 0.50 0.25 0.25 0.25 0.25 - - - - - - blsrq (%rax), %rcx
-# CHECK-NEXT: - - 0.25 0.25 0.25 0.25 - - - - - - tzcntw %ax, %cx
-# CHECK-NEXT: 0.50 0.50 0.25 0.25 0.25 0.25 - - - - - - tzcntw (%rax), %cx
-# CHECK-NEXT: - - 0.25 0.25 0.25 0.25 - - - - - - tzcntl %eax, %ecx
-# CHECK-NEXT: 0.50 0.50 0.25 0.25 0.25 0.25 - - - - - - tzcntl (%rax), %ecx
-# CHECK-NEXT: - - 0.25 0.25 0.25 0.25 - - - - - - tzcntq %rax, %rcx
-# CHECK-NEXT: 0.50 0.50 0.25 0.25 0.25 0.25 - - - - - - tzcntq (%rax), %rcx
+# CHECK-NEXT: - - 0.50 0.50 0.50 0.50 - - - - - - blsil %eax, %ecx
+# CHECK-NEXT: 0.50 0.50 0.50 0.50 0.50 0.50 - - - - - - blsil (%rax), %ecx
+# CHECK-NEXT: - - 0.50 0.50 0.50 0.50 - - - - - - blsiq %rax, %rcx
+# CHECK-NEXT: 0.50 0.50 0.50 0.50 0.50 0.50 - - - - - - blsiq (%rax), %rcx
+# CHECK-NEXT: - - 0.50 0.50 0.50 0.50 - - - - - - blsmskl %eax, %ecx
+# CHECK-NEXT: 0.50 0.50 0.50 0.50 0.50 0.50 - - - - - - blsmskl (%rax), %ecx
+# CHECK-NEXT: - - 0.50 0.50 0.50 0.50 - - - - - - blsmskq %rax, %rcx
+# CHECK-NEXT: 0.50 0.50 0.50 0.50 0.50 0.50 - - - - - - blsmskq (%rax), %rcx
+# CHECK-NEXT: - - 0.50 0.50 0.50 0.50 - - - - - - blsrl %eax, %ecx
+# CHECK-NEXT: 0.50 0.50 0.50 0.50 0.50 0.50 - - - - - - blsrl (%rax), %ecx
+# CHECK-NEXT: - - 0.50 0.50 0.50 0.50 - - - - - - blsrq %rax, %rcx
+# CHECK-NEXT: 0.50 0.50 0.50 0.50 0.50 0.50 - - - - - - blsrq (%rax), %rcx
+# CHECK-NEXT: - - 0.50 0.50 0.50 0.50 - - - - - - tzcntw %ax, %cx
+# CHECK-NEXT: 0.50 0.50 0.50 0.50 0.50 0.50 - - - - - - tzcntw (%rax), %cx
+# CHECK-NEXT: - - 0.50 0.50 0.50 0.50 - - - - - - tzcntl %eax, %ecx
+# CHECK-NEXT: 0.50 0.50 0.50 0.50 0.50 0.50 - - - - - - tzcntl (%rax), %ecx
+# CHECK-NEXT: - - 0.50 0.50 0.50 0.50 - - - - - - tzcntq %rax, %rcx
+# CHECK-NEXT: 0.50 0.50 0.50 0.50 0.50 0.50 - - - - - - tzcntq (%rax), %rcx
diff --git a/llvm/test/tools/llvm-mca/X86/Znver2/resources-bmi1.s b/llvm/test/tools/llvm-mca/X86/Znver2/resources-bmi1.s
index 8db8286ad211..cff0df561353 100644
--- a/llvm/test/tools/llvm-mca/X86/Znver2/resources-bmi1.s
+++ b/llvm/test/tools/llvm-mca/X86/Znver2/resources-bmi1.s
@@ -57,24 +57,24 @@ tzcnt (%rax), %rcx
# CHECK-NEXT: 2 5 0.33 * bextrl %eax, (%rbx), %ecx
# CHECK-NEXT: 1 1 0.25 bextrq %rax, %rbx, %rcx
# CHECK-NEXT: 2 5 0.33 * bextrq %rax, (%rbx), %rcx
-# CHECK-NEXT: 2 2 0.25 blsil %eax, %ecx
-# CHECK-NEXT: 3 6 0.33 * blsil (%rax), %ecx
-# CHECK-NEXT: 2 2 0.25 blsiq %rax, %rcx
-# CHECK-NEXT: 3 6 0.33 * blsiq (%rax), %rcx
-# CHECK-NEXT: 2 2 0.25 blsmskl %eax, %ecx
-# CHECK-NEXT: 3 6 0.33 * blsmskl (%rax), %ecx
-# CHECK-NEXT: 2 2 0.25 blsmskq %rax, %rcx
-# CHECK-NEXT: 3 6 0.33 * blsmskq (%rax), %rcx
-# CHECK-NEXT: 2 2 0.25 blsrl %eax, %ecx
-# CHECK-NEXT: 3 6 0.33 * blsrl (%rax), %ecx
-# CHECK-NEXT: 2 2 0.25 blsrq %rax, %rcx
-# CHECK-NEXT: 3 6 0.33 * blsrq (%rax), %rcx
-# CHECK-NEXT: 1 2 0.25 tzcntw %ax, %cx
-# CHECK-NEXT: 2 6 0.33 * tzcntw (%rax), %cx
-# CHECK-NEXT: 1 2 0.25 tzcntl %eax, %ecx
-# CHECK-NEXT: 2 6 0.33 * tzcntl (%rax), %ecx
-# CHECK-NEXT: 1 2 0.25 tzcntq %rax, %rcx
-# CHECK-NEXT: 2 6 0.33 * tzcntq (%rax), %rcx
+# CHECK-NEXT: 2 2 0.50 blsil %eax, %ecx
+# CHECK-NEXT: 3 6 0.50 * blsil (%rax), %ecx
+# CHECK-NEXT: 2 2 0.50 blsiq %rax, %rcx
+# CHECK-NEXT: 3 6 0.50 * blsiq (%rax), %rcx
+# CHECK-NEXT: 2 2 0.50 blsmskl %eax, %ecx
+# CHECK-NEXT: 3 6 0.50 * blsmskl (%rax), %ecx
+# CHECK-NEXT: 2 2 0.50 blsmskq %rax, %rcx
+# CHECK-NEXT: 3 6 0.50 * blsmskq (%rax), %rcx
+# CHECK-NEXT: 2 2 0.50 blsrl %eax, %ecx
+# CHECK-NEXT: 3 6 0.50 * blsrl (%rax), %ecx
+# CHECK-NEXT: 2 2 0.50 blsrq %rax, %rcx
+# CHECK-NEXT: 3 6 0.50 * blsrq (%rax), %rcx
+# CHECK-NEXT: 2 2 0.50 tzcntw %ax, %cx
+# CHECK-NEXT: 2 6 0.50 * tzcntw (%rax), %cx
+# CHECK-NEXT: 2 2 0.50 tzcntl %eax, %ecx
+# CHECK-NEXT: 2 6 0.50 * tzcntl (%rax), %ecx
+# CHECK-NEXT: 2 2 0.50 tzcntq %rax, %rcx
+# CHECK-NEXT: 2 6 0.50 * tzcntq (%rax), %rcx
# CHECK: Resources:
# CHECK-NEXT: [0] - Zn2AGU0
@@ -93,7 +93,7 @@ tzcnt (%rax), %rcx
# CHECK: Resource pressure per iteration:
# CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]
-# CHECK-NEXT: 4.33 4.33 4.33 6.50 6.50 6.50 6.50 - - - - - -
+# CHECK-NEXT: 4.33 4.33 4.33 11.00 11.00 11.00 11.00 - - - - - -
# CHECK: Resource pressure by instruction:
# CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] Instructions:
@@ -105,21 +105,21 @@ tzcnt (%rax), %rcx
# CHECK-NEXT: 0.33 0.33 0.33 0.25 0.25 0.25 0.25 - - - - - - bextrl %eax, (%rbx), %ecx
# CHECK-NEXT: - - - 0.25 0.25 0.25 0.25 - - - - - - bextrq %rax, %rbx, %rcx
# CHECK-NEXT: 0.33 0.33 0.33 0.25 0.25 0.25 0.25 - - - - - - bextrq %rax, (%rbx), %rcx
-# CHECK-NEXT: - - - 0.25 0.25 0.25 0.25 - - - - - - blsil %eax, %ecx
-# CHECK-NEXT: 0.33 0.33 0.33 0.25 0.25 0.25 0.25 - - - - - - blsil (%rax), %ecx
-# CHECK-NEXT: - - - 0.25 0.25 0.25 0.25 - - - - - - blsiq %rax, %rcx
-# CHECK-NEXT: 0.33 0.33 0.33 0.25 0.25 0.25 0.25 - - - - - - blsiq (%rax), %rcx
-# CHECK-NEXT: - - - 0.25 0.25 0.25 0.25 - - - - - - blsmskl %eax, %ecx
-# CHECK-NEXT: 0.33 0.33 0.33 0.25 0.25 0.25 0.25 - - - - - - blsmskl (%rax), %ecx
-# CHECK-NEXT: - - - 0.25 0.25 0.25 0.25 - - - - - - blsmskq %rax, %rcx
-# CHECK-NEXT: 0.33 0.33 0.33 0.25 0.25 0.25 0.25 - - - - - - blsmskq (%rax), %rcx
-# CHECK-NEXT: - - - 0.25 0.25 0.25 0.25 - - - - - - blsrl %eax, %ecx
-# CHECK-NEXT: 0.33 0.33 0.33 0.25 0.25 0.25 0.25 - - - - - - blsrl (%rax), %ecx
-# CHECK-NEXT: - - - 0.25 0.25 0.25 0.25 - - - - - - blsrq %rax, %rcx
-# CHECK-NEXT: 0.33 0.33 0.33 0.25 0.25 0.25 0.25 - - - - - - blsrq (%rax), %rcx
-# CHECK-NEXT: - - - 0.25 0.25 0.25 0.25 - - - - - - tzcntw %ax, %cx
-# CHECK-NEXT: 0.33 0.33 0.33 0.25 0.25 0.25 0.25 - - - - - - tzcntw (%rax), %cx
-# CHECK-NEXT: - - - 0.25 0.25 0.25 0.25 - - - - - - tzcntl %eax, %ecx
-# CHECK-NEXT: 0.33 0.33 0.33 0.25 0.25 0.25 0.25 - - - - - - tzcntl (%rax), %ecx
-# CHECK-NEXT: - - - 0.25 0.25 0.25 0.25 - - - - - - tzcntq %rax, %rcx
-# CHECK-NEXT: 0.33 0.33 0.33 0.25 0.25 0.25 0.25 - - - - - - tzcntq (%rax), %rcx
+# CHECK-NEXT: - - - 0.50 0.50 0.50 0.50 - - - - - - blsil %eax, %ecx
+# CHECK-NEXT: 0.33 0.33 0.33 0.50 0.50 0.50 0.50 - - - - - - blsil (%rax), %ecx
+# CHECK-NEXT: - - - 0.50 0.50 0.50 0.50 - - - - - - blsiq %rax, %rcx
+# CHECK-NEXT: 0.33 0.33 0.33 0.50 0.50 0.50 0.50 - - - - - - blsiq (%rax), %rcx
+# CHECK-NEXT: - - - 0.50 0.50 0.50 0.50 - - - - - - blsmskl %eax, %ecx
+# CHECK-NEXT: 0.33 0.33 0.33 0.50 0.50 0.50 0.50 - - - - - - blsmskl (%rax), %ecx
+# CHECK-NEXT: - - - 0.50 0.50 0.50 0.50 - - - - - - blsmskq %rax, %rcx
+# CHECK-NEXT: 0.33 0.33 0.33 0.50 0.50 0.50 0.50 - - - - - - blsmskq (%rax), %rcx
+# CHECK-NEXT: - - - 0.50 0.50 0.50 0.50 - - - - - - blsrl %eax, %ecx
+# CHECK-NEXT: 0.33 0.33 0.33 0.50 0.50 0.50 0.50 - - - - - - blsrl (%rax), %ecx
+# CHECK-NEXT: - - - 0.50 0.50 0.50 0.50 - - - - - - blsrq %rax, %rcx
+# CHECK-NEXT: 0.33 0.33 0.33 0.50 0.50 0.50 0.50 - - - - - - blsrq (%rax), %rcx
+# CHECK-NEXT: - - - 0.50 0.50 0.50 0.50 - - - - - - tzcntw %ax, %cx
+# CHECK-NEXT: 0.33 0.33 0.33 0.50 0.50 0.50 0.50 - - - - - - tzcntw (%rax), %cx
+# CHECK-NEXT: - - - 0.50 0.50 0.50 0.50 - - - - - - tzcntl %eax, %ecx
+# CHECK-NEXT: 0.33 0.33 0.33 0.50 0.50 0.50 0.50 - - - - - - tzcntl (%rax), %ecx
+# CHECK-NEXT: - - - 0.50 0.50 0.50 0.50 - - - - - - tzcntq %rax, %rcx
+# CHECK-NEXT: 0.33 0.33 0.33 0.50 0.50 0.50 0.50 - - - - - - tzcntq (%rax), %rcx
More information about the llvm-commits
mailing list