[llvm] e16b4f5 - [X86] Fix SLM uops/resources counts for CMPXCHG instructions
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 20 05:07:19 PST 2022
Author: Simon Pilgrim
Date: 2022-12-20T13:07:03Z
New Revision: e16b4f5b16a3d6b3753ce1a45d40113c8cb6bc23
URL: https://github.com/llvm/llvm-project/commit/e16b4f5b16a3d6b3753ce1a45d40113c8cb6bc23
DIFF: https://github.com/llvm/llvm-project/commit/e16b4f5b16a3d6b3753ce1a45d40113c8cb6bc23.diff
LOG: [X86] Fix SLM uops/resources counts for CMPXCHG instructions
LOCK + CMPXCHG8/CMPXCHG16 variants still need overriding as they are not completely correct - already much better though
Based off llvm-exegesis captures, confirmed with Agner + uops.info
Added:
Modified:
llvm/lib/Target/X86/X86ScheduleSLM.td
llvm/test/tools/llvm-mca/X86/SLM/resources-cmpxchg.s
llvm/test/tools/llvm-mca/X86/SLM/resources-x86_64.s
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86ScheduleSLM.td b/llvm/lib/Target/X86/X86ScheduleSLM.td
index ea6f74e304ccb..c59853bd71041 100644
--- a/llvm/lib/Target/X86/X86ScheduleSLM.td
+++ b/llvm/lib/Target/X86/X86ScheduleSLM.td
@@ -117,8 +117,8 @@ defm : X86WriteResPairUnsupported<WriteMULX64>;
defm : X86WriteRes<WriteBSWAP32, [SLM_IEC_RSV01], 1, [1], 1>;
defm : X86WriteRes<WriteBSWAP64, [SLM_IEC_RSV01], 1, [1], 1>;
-defm : X86WriteRes<WriteCMPXCHG, [SLM_IEC_RSV01], 1, [1], 1>;
-defm : X86WriteRes<WriteCMPXCHGRMW, [SLM_IEC_RSV01, SLM_MEC_RSV], 4, [1, 2], 2>;
+defm : X86WriteRes<WriteCMPXCHG, [SLM_IEC_RSV01], 6, [6], 5>;
+defm : X86WriteRes<WriteCMPXCHGRMW, [SLM_IEC_RSV01, SLM_MEC_RSV], 10, [6, 2], 8>;
defm : X86WriteRes<WriteXCHG, [SLM_IEC_RSV01], 1, [1], 1>;
defm : SLMWriteResPair<WriteShift, [SLM_IEC_RSV0], 1>;
diff --git a/llvm/test/tools/llvm-mca/X86/SLM/resources-cmpxchg.s b/llvm/test/tools/llvm-mca/X86/SLM/resources-cmpxchg.s
index f6636d378b4ed..86143c5f3926d 100644
--- a/llvm/test/tools/llvm-mca/X86/SLM/resources-cmpxchg.s
+++ b/llvm/test/tools/llvm-mca/X86/SLM/resources-cmpxchg.s
@@ -15,10 +15,10 @@ lock cmpxchg16b (%rax)
# CHECK-NEXT: [6]: HasSideEffects (U)
# CHECK: [1] [2] [3] [4] [5] [6] Instructions:
-# CHECK-NEXT: 2 4 2.00 * * cmpxchg8b (%rax)
-# CHECK-NEXT: 2 4 2.00 * * cmpxchg16b (%rax)
-# CHECK-NEXT: 2 4 2.00 * * lock cmpxchg8b (%rax)
-# CHECK-NEXT: 2 4 2.00 * * lock cmpxchg16b (%rax)
+# CHECK-NEXT: 8 10 3.00 * * cmpxchg8b (%rax)
+# CHECK-NEXT: 8 10 3.00 * * cmpxchg16b (%rax)
+# CHECK-NEXT: 8 10 3.00 * * lock cmpxchg8b (%rax)
+# CHECK-NEXT: 8 10 3.00 * * lock cmpxchg16b (%rax)
# CHECK: Resources:
# CHECK-NEXT: [0] - SLMDivider
@@ -32,11 +32,11 @@ lock cmpxchg16b (%rax)
# CHECK: Resource pressure per iteration:
# CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7]
-# CHECK-NEXT: - - - - - 2.00 2.00 8.00
+# CHECK-NEXT: - - - - - 12.00 12.00 8.00
# CHECK: Resource pressure by instruction:
# CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] Instructions:
-# CHECK-NEXT: - - - - - 0.50 0.50 2.00 cmpxchg8b (%rax)
-# CHECK-NEXT: - - - - - 0.50 0.50 2.00 cmpxchg16b (%rax)
-# CHECK-NEXT: - - - - - 0.50 0.50 2.00 lock cmpxchg8b (%rax)
-# CHECK-NEXT: - - - - - 0.50 0.50 2.00 lock cmpxchg16b (%rax)
+# CHECK-NEXT: - - - - - 3.00 3.00 2.00 cmpxchg8b (%rax)
+# CHECK-NEXT: - - - - - 3.00 3.00 2.00 cmpxchg16b (%rax)
+# CHECK-NEXT: - - - - - 3.00 3.00 2.00 lock cmpxchg8b (%rax)
+# CHECK-NEXT: - - - - - 3.00 3.00 2.00 lock cmpxchg16b (%rax)
diff --git a/llvm/test/tools/llvm-mca/X86/SLM/resources-x86_64.s b/llvm/test/tools/llvm-mca/X86/SLM/resources-x86_64.s
index 7b27f1b1da2bb..15441afaf7b82 100644
--- a/llvm/test/tools/llvm-mca/X86/SLM/resources-x86_64.s
+++ b/llvm/test/tools/llvm-mca/X86/SLM/resources-x86_64.s
@@ -1296,18 +1296,18 @@ xorq (%rax), %rdi
# CHECK-NEXT: 1 100 1.00 U cmpsw %es:(%rdi), (%rsi)
# CHECK-NEXT: 1 100 1.00 U cmpsl %es:(%rdi), (%rsi)
# CHECK-NEXT: 1 100 1.00 U cmpsq %es:(%rdi), (%rsi)
-# CHECK-NEXT: 1 1 0.50 cmpxchgb %cl, %bl
-# CHECK-NEXT: 2 4 2.00 * * cmpxchgb %cl, (%rbx)
-# CHECK-NEXT: 2 4 2.00 * * lock cmpxchgb %cl, (%rbx)
-# CHECK-NEXT: 1 1 0.50 cmpxchgw %cx, %bx
-# CHECK-NEXT: 2 4 2.00 * * cmpxchgw %cx, (%rbx)
-# CHECK-NEXT: 2 4 2.00 * * lock cmpxchgw %cx, (%rbx)
-# CHECK-NEXT: 1 1 0.50 cmpxchgl %ecx, %ebx
-# CHECK-NEXT: 2 4 2.00 * * cmpxchgl %ecx, (%rbx)
-# CHECK-NEXT: 2 4 2.00 * * lock cmpxchgl %ecx, (%rbx)
-# CHECK-NEXT: 1 1 0.50 cmpxchgq %rcx, %rbx
-# CHECK-NEXT: 2 4 2.00 * * cmpxchgq %rcx, (%rbx)
-# CHECK-NEXT: 2 4 2.00 * * lock cmpxchgq %rcx, (%rbx)
+# CHECK-NEXT: 5 6 3.00 cmpxchgb %cl, %bl
+# CHECK-NEXT: 8 10 3.00 * * cmpxchgb %cl, (%rbx)
+# CHECK-NEXT: 8 10 3.00 * * lock cmpxchgb %cl, (%rbx)
+# CHECK-NEXT: 5 6 3.00 cmpxchgw %cx, %bx
+# CHECK-NEXT: 8 10 3.00 * * cmpxchgw %cx, (%rbx)
+# CHECK-NEXT: 8 10 3.00 * * lock cmpxchgw %cx, (%rbx)
+# CHECK-NEXT: 5 6 3.00 cmpxchgl %ecx, %ebx
+# CHECK-NEXT: 8 10 3.00 * * cmpxchgl %ecx, (%rbx)
+# CHECK-NEXT: 8 10 3.00 * * lock cmpxchgl %ecx, (%rbx)
+# CHECK-NEXT: 5 6 3.00 cmpxchgq %rcx, %rbx
+# CHECK-NEXT: 8 10 3.00 * * cmpxchgq %rcx, (%rbx)
+# CHECK-NEXT: 8 10 3.00 * * lock cmpxchgq %rcx, (%rbx)
# CHECK-NEXT: 1 100 1.00 U cpuid
# CHECK-NEXT: 1 1 0.50 decb %dil
# CHECK-NEXT: 1 5 2.00 * * decb (%rax)
@@ -1960,7 +1960,7 @@ xorq (%rax), %rdi
# CHECK: Resource pressure per iteration:
# CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7]
-# CHECK-NEXT: 400.00 - - 49.00 - 654.50 595.50 835.00
+# CHECK-NEXT: 400.00 - - 49.00 - 684.50 625.50 835.00
# CHECK: Resource pressure by instruction:
# CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] Instructions:
@@ -2226,18 +2226,18 @@ xorq (%rax), %rdi
# CHECK-NEXT: - - - 1.00 - - - - cmpsw %es:(%rdi), (%rsi)
# CHECK-NEXT: - - - 1.00 - - - - cmpsl %es:(%rdi), (%rsi)
# CHECK-NEXT: - - - 1.00 - - - - cmpsq %es:(%rdi), (%rsi)
-# CHECK-NEXT: - - - - - 0.50 0.50 - cmpxchgb %cl, %bl
-# CHECK-NEXT: - - - - - 0.50 0.50 2.00 cmpxchgb %cl, (%rbx)
-# CHECK-NEXT: - - - - - 0.50 0.50 2.00 lock cmpxchgb %cl, (%rbx)
-# CHECK-NEXT: - - - - - 0.50 0.50 - cmpxchgw %cx, %bx
-# CHECK-NEXT: - - - - - 0.50 0.50 2.00 cmpxchgw %cx, (%rbx)
-# CHECK-NEXT: - - - - - 0.50 0.50 2.00 lock cmpxchgw %cx, (%rbx)
-# CHECK-NEXT: - - - - - 0.50 0.50 - cmpxchgl %ecx, %ebx
-# CHECK-NEXT: - - - - - 0.50 0.50 2.00 cmpxchgl %ecx, (%rbx)
-# CHECK-NEXT: - - - - - 0.50 0.50 2.00 lock cmpxchgl %ecx, (%rbx)
-# CHECK-NEXT: - - - - - 0.50 0.50 - cmpxchgq %rcx, %rbx
-# CHECK-NEXT: - - - - - 0.50 0.50 2.00 cmpxchgq %rcx, (%rbx)
-# CHECK-NEXT: - - - - - 0.50 0.50 2.00 lock cmpxchgq %rcx, (%rbx)
+# CHECK-NEXT: - - - - - 3.00 3.00 - cmpxchgb %cl, %bl
+# CHECK-NEXT: - - - - - 3.00 3.00 2.00 cmpxchgb %cl, (%rbx)
+# CHECK-NEXT: - - - - - 3.00 3.00 2.00 lock cmpxchgb %cl, (%rbx)
+# CHECK-NEXT: - - - - - 3.00 3.00 - cmpxchgw %cx, %bx
+# CHECK-NEXT: - - - - - 3.00 3.00 2.00 cmpxchgw %cx, (%rbx)
+# CHECK-NEXT: - - - - - 3.00 3.00 2.00 lock cmpxchgw %cx, (%rbx)
+# CHECK-NEXT: - - - - - 3.00 3.00 - cmpxchgl %ecx, %ebx
+# CHECK-NEXT: - - - - - 3.00 3.00 2.00 cmpxchgl %ecx, (%rbx)
+# CHECK-NEXT: - - - - - 3.00 3.00 2.00 lock cmpxchgl %ecx, (%rbx)
+# CHECK-NEXT: - - - - - 3.00 3.00 - cmpxchgq %rcx, %rbx
+# CHECK-NEXT: - - - - - 3.00 3.00 2.00 cmpxchgq %rcx, (%rbx)
+# CHECK-NEXT: - - - - - 3.00 3.00 2.00 lock cmpxchgq %rcx, (%rbx)
# CHECK-NEXT: - - - 1.00 - - - - cpuid
# CHECK-NEXT: - - - - - 0.50 0.50 - decb %dil
# CHECK-NEXT: - - - - - 0.50 0.50 2.00 decb (%rax)
More information about the llvm-commits
mailing list