diff --git a/llvm/lib/Target/X86/X86InstrArithmetic.td b/llvm/lib/Target/X86/X86InstrArithmetic.td index e83e1e74ff52..ba00e7da81f9 100644 --- a/llvm/lib/Target/X86/X86InstrArithmetic.td +++ b/llvm/lib/Target/X86/X86InstrArithmetic.td @@ -708,6 +708,19 @@ class BinOpRM opcode, string mnemonic, X86TypeInfo typeinfo, mnemonic, "{$src2, $src1|$src1, $src2}", pattern>, Sched<[sched.Folded, sched.ReadAfterFold]>; +// BinOpRM - Instructions like "adc reg, reg, [mem]". +// There is an implicit register read at the end of the operand sequence. +class BinOpRM_ImplicitUse opcode, string mnemonic, X86TypeInfo typeinfo, + dag outlist, X86FoldableSchedWrite sched, list pattern> + : ITy, + Sched<[sched.Folded, sched.ReadAfterFold, + // base, scale, index, offset, segment. + ReadDefault, ReadDefault, ReadDefault, ReadDefault, ReadDefault, + // implicit register read. + sched.ReadAfterFold]>; + // BinOpRM_F - Instructions like "cmp reg, [mem]". class BinOpRM_F opcode, string mnemonic, X86TypeInfo typeinfo, SDNode opnode> @@ -725,7 +738,7 @@ class BinOpRM_RF opcode, string mnemonic, X86TypeInfo typeinfo, // BinOpRM_RFF - Instructions like "adc reg, reg, [mem]". class BinOpRM_RFF opcode, string mnemonic, X86TypeInfo typeinfo, SDNode opnode> - : BinOpRM; @@ -805,7 +818,11 @@ class BinOpMR_RMW opcode, string mnemonic, X86TypeInfo typeinfo, SDNode opnode> : BinOpMR, Sched<[WriteALURMW]>; + (implicit EFLAGS)]>, Sched<[WriteALURMW, + // base, scale, index, offset, segment + ReadDefault, ReadDefault, ReadDefault, + ReadDefault, ReadDefault, + WriteALU.ReadAfterFold]>; // reg // BinOpMR_RMW_FF - Instructions like "adc [mem], reg". class BinOpMR_RMW_FF opcode, string mnemonic, X86TypeInfo typeinfo, @@ -813,7 +830,12 @@ class BinOpMR_RMW_FF opcode, string mnemonic, X86TypeInfo typeinfo, : BinOpMR, Sched<[WriteADCRMW]>; + (implicit EFLAGS)]>, Sched<[WriteADCRMW, + // base, scale, index, offset, segment + ReadDefault, ReadDefault, ReadDefault, + ReadDefault, ReadDefault, + WriteALU.ReadAfterFold, // reg + WriteALU.ReadAfterFold]>; // EFLAGS // BinOpMR_F - Instructions like "cmp [mem], reg". class BinOpMR_F opcode, string mnemonic, X86TypeInfo typeinfo, diff --git a/llvm/test/tools/llvm-mca/X86/BtVer2/adc-sequence-readadvance.s b/llvm/test/tools/llvm-mca/X86/BtVer2/adc-sequence-readadvance.s index 68537e4f7674..4d563adf0cbf 100644 --- a/llvm/test/tools/llvm-mca/X86/BtVer2/adc-sequence-readadvance.s +++ b/llvm/test/tools/llvm-mca/X86/BtVer2/adc-sequence-readadvance.s @@ -1,19 +1,16 @@ # NOTE: Assertions have been autogenerated by utils/update_mca_test_checks.py # RUN: llvm-mca -mtriple=x86_64-unknown-unknown -mcpu=btver2 -iterations=4 -timeline < %s | FileCheck %s -# FIXME: PR51318 -# Missing read-advance for the implicit use of register EFLAGS. - adc 4(%rsp), %eax # CHECK: Iterations: 4 # CHECK-NEXT: Instructions: 4 -# CHECK-NEXT: Total Cycles: 19 +# CHECK-NEXT: Total Cycles: 10 # CHECK-NEXT: Total uOps: 4 # CHECK: Dispatch Width: 2 -# CHECK-NEXT: uOps Per Cycle: 0.21 -# CHECK-NEXT: IPC: 0.21 +# CHECK-NEXT: uOps Per Cycle: 0.40 +# CHECK-NEXT: IPC: 0.40 # CHECK-NEXT: Block RThroughput: 1.0 # CHECK: Instruction Info: @@ -52,13 +49,12 @@ adc 4(%rsp), %eax # CHECK-NEXT: 1.00 1.00 - - - - - 1.00 - - - - - - adcl 4(%rsp), %eax # CHECK: Timeline view: -# CHECK-NEXT: 012345678 # CHECK-NEXT: Index 0123456789 -# CHECK: [0,0] DeeeeER . . . adcl 4(%rsp), %eax -# CHECK-NEXT: [1,0] D====eeeeER . . adcl 4(%rsp), %eax -# CHECK-NEXT: [2,0] .D=======eeeeER. . adcl 4(%rsp), %eax -# CHECK-NEXT: [3,0] .D===========eeeeER adcl 4(%rsp), %eax +# CHECK: [0,0] DeeeeER . adcl 4(%rsp), %eax +# CHECK-NEXT: [1,0] D=eeeeER . adcl 4(%rsp), %eax +# CHECK-NEXT: [2,0] .D=eeeeER. adcl 4(%rsp), %eax +# CHECK-NEXT: [3,0] .D==eeeeER adcl 4(%rsp), %eax # CHECK: Average Wait times (based on the timeline view): # CHECK-NEXT: [0]: Executions @@ -67,4 +63,4 @@ adc 4(%rsp), %eax # CHECK-NEXT: [3]: Average time elapsed from WB until retire stage # CHECK: [0] [1] [2] [3] -# CHECK-NEXT: 0. 4 6.5 0.3 0.0 adcl 4(%rsp), %eax +# CHECK-NEXT: 0. 4 2.0 0.3 0.0 adcl 4(%rsp), %eax diff --git a/llvm/test/tools/llvm-mca/X86/BtVer2/rmw-adc-sequence-readadvance.s b/llvm/test/tools/llvm-mca/X86/BtVer2/rmw-adc-sequence-readadvance.s index 16387c6c26e9..ef25a48f4a72 100644 --- a/llvm/test/tools/llvm-mca/X86/BtVer2/rmw-adc-sequence-readadvance.s +++ b/llvm/test/tools/llvm-mca/X86/BtVer2/rmw-adc-sequence-readadvance.s @@ -1,20 +1,17 @@ # NOTE: Assertions have been autogenerated by utils/update_mca_test_checks.py # RUN: llvm-mca -mtriple=x86_64-unknown-unknown -mcpu=btver2 -iterations=1 -timeline < %s | FileCheck %s -# FIXME: PR51322 -# Missing read-advance for register EAX. - add %eax, %eax adc %eax, 4(%rsp) # CHECK: Iterations: 1 # CHECK-NEXT: Instructions: 2 -# CHECK-NEXT: Total Cycles: 10 +# CHECK-NEXT: Total Cycles: 9 # CHECK-NEXT: Total uOps: 2 # CHECK: Dispatch Width: 2 -# CHECK-NEXT: uOps Per Cycle: 0.20 -# CHECK-NEXT: IPC: 0.20 +# CHECK-NEXT: uOps Per Cycle: 0.22 +# CHECK-NEXT: IPC: 0.22 # CHECK-NEXT: Block RThroughput: 1.5 # CHECK: Instruction Info: @@ -55,10 +52,10 @@ adc %eax, 4(%rsp) # CHECK-NEXT: 2.00 - - - - - - 1.00 - 1.00 - - - - adcl %eax, 4(%rsp) # CHECK: Timeline view: -# CHECK-NEXT: Index 0123456789 +# CHECK-NEXT: Index 012345678 -# CHECK: [0,0] DeER . . addl %eax, %eax -# CHECK-NEXT: [0,1] D=eeeeeeER adcl %eax, 4(%rsp) +# CHECK: [0,0] DeER . . addl %eax, %eax +# CHECK-NEXT: [0,1] DeeeeeeER adcl %eax, 4(%rsp) # CHECK: Average Wait times (based on the timeline view): # CHECK-NEXT: [0]: Executions @@ -68,5 +65,5 @@ adc %eax, 4(%rsp) # CHECK: [0] [1] [2] [3] # CHECK-NEXT: 0. 1 1.0 1.0 0.0 addl %eax, %eax -# CHECK-NEXT: 1. 1 2.0 0.0 0.0 adcl %eax, 4(%rsp) -# CHECK-NEXT: 1 1.5 0.5 0.0 +# CHECK-NEXT: 1. 1 1.0 0.0 0.0 adcl %eax, 4(%rsp) +# CHECK-NEXT: 1 1.0 0.5 0.0 diff --git a/llvm/test/tools/llvm-mca/X86/BtVer2/rmw-add-sequence-readadvance.s b/llvm/test/tools/llvm-mca/X86/BtVer2/rmw-add-sequence-readadvance.s index 7ff8884da852..a8da4515b315 100644 --- a/llvm/test/tools/llvm-mca/X86/BtVer2/rmw-add-sequence-readadvance.s +++ b/llvm/test/tools/llvm-mca/X86/BtVer2/rmw-add-sequence-readadvance.s @@ -1,20 +1,17 @@ # NOTE: Assertions have been autogenerated by utils/update_mca_test_checks.py # RUN: llvm-mca -mtriple=x86_64-unknown-unknown -mcpu=btver2 -iterations=1 -timeline < %s | FileCheck %s -# FIXME: PR51322 -# Missing read-advance for register EAX. - add %eax, %eax add %eax, 4(%rsp) # CHECK: Iterations: 1 # CHECK-NEXT: Instructions: 2 -# CHECK-NEXT: Total Cycles: 10 +# CHECK-NEXT: Total Cycles: 9 # CHECK-NEXT: Total uOps: 2 # CHECK: Dispatch Width: 2 -# CHECK-NEXT: uOps Per Cycle: 0.20 -# CHECK-NEXT: IPC: 0.20 +# CHECK-NEXT: uOps Per Cycle: 0.22 +# CHECK-NEXT: IPC: 0.22 # CHECK-NEXT: Block RThroughput: 1.0 # CHECK: Instruction Info: @@ -55,10 +52,10 @@ add %eax, 4(%rsp) # CHECK-NEXT: 1.00 - - - - - - 1.00 - 1.00 - - - - addl %eax, 4(%rsp) # CHECK: Timeline view: -# CHECK-NEXT: Index 0123456789 +# CHECK-NEXT: Index 012345678 -# CHECK: [0,0] DeER . . addl %eax, %eax -# CHECK-NEXT: [0,1] D=eeeeeeER addl %eax, 4(%rsp) +# CHECK: [0,0] DeER . . addl %eax, %eax +# CHECK-NEXT: [0,1] DeeeeeeER addl %eax, 4(%rsp) # CHECK: Average Wait times (based on the timeline view): # CHECK-NEXT: [0]: Executions @@ -68,5 +65,5 @@ add %eax, 4(%rsp) # CHECK: [0] [1] [2] [3] # CHECK-NEXT: 0. 1 1.0 1.0 0.0 addl %eax, %eax -# CHECK-NEXT: 1. 1 2.0 0.0 0.0 addl %eax, 4(%rsp) -# CHECK-NEXT: 1 1.5 0.5 0.0 +# CHECK-NEXT: 1. 1 1.0 0.0 0.0 addl %eax, 4(%rsp) +# CHECK-NEXT: 1 1.0 0.5 0.0