[X86][Sched] Add InstRW for CLC on Intel after SNB.

Summary:
After SNB, Intel CPUs can rename CF independently of other EFLAGS,
so the renamer can zero it for free. Note that STC still consumes resources.

To reproduce: `$ llvm-exegesis -mode=uops -opcode-name=CLC`

On SNB:
```
---
key:
  opcode_name:     CLC
  mode:            uops
  config:          ''
cpu_name:        sandybridge
llvm_triple:     x86_64-unknown-linux-gnu
num_repetitions: 10000
measurements:
  - { key: '3', value: 0.0014, debug_string: SBPort0 }
  - { key: '4', value: 0.0013, debug_string: SBPort1 }
  - { key: '5', value: 0.0003, debug_string: SBPort4 }
  - { key: '6', value: 0.0029, debug_string: SBPort5 }
  - { key: '10', value: 0.0003, debug_string: SBPort23 }
error:           ''
info:            'instruction is serial, repeating a random one.
Snippet:
CLC
'
...
```

On HSW:
```
---
key:
  opcode_name:     CLC
  mode:            uops
  config:          ''
cpu_name:        haswell
llvm_triple:     x86_64-unknown-linux-gnu
num_repetitions: 10000
measurements:
  - { key: '3', value: 0.001, debug_string: HWPort0 }
  - { key: '4', value: 0.0009, debug_string: HWPort1 }
  - { key: '5', value: 0.0004, debug_string: HWPort2 }
  - { key: '6', value: 0.0006, debug_string: HWPort3 }
  - { key: '7', value: 0.0002, debug_string: HWPort4 }
  - { key: '8', value: 0.0012, debug_string: HWPort5 }
  - { key: '9', value: 0.0022, debug_string: HWPort6 }
  - { key: '10', value: 0.0001, debug_string: HWPort7 }
error:           ''
info:            'instruction is serial, repeating a random one.
Snippet:
CLC
'
...

```

Reviewers: craig.topper, RKSimon

Subscribers: gchatelet, llvm-commits

Differential Revision: https://reviews.llvm.org/D47362

llvm-svn: 333392
This commit is contained in:
Clement Courbet 2018-05-29 06:19:39 +00:00
parent edc8d889b9
commit 07c9ec6f2e
15 changed files with 60 additions and 13 deletions

View File

@ -1682,5 +1682,7 @@ def BWWriteResGroup202 : SchedWriteRes<[BWPort0,BWPort1,BWPort4,BWPort5,BWPort6,
}
def: InstRW<[BWWriteResGroup202], (instrs FSTENVm)>;
def: InstRW<[WriteZero], (instrs CLC)>;
} // SchedModel

View File

@ -866,7 +866,7 @@ def HWWriteResGroup10 : SchedWriteRes<[HWPort0156]> {
let ResourceCycles = [1];
}
def: InstRW<[HWWriteResGroup10], (instrs CBW, CWDE, CDQE,
CLC, CMC, STC)>;
CMC, STC)>;
def: InstRW<[HWWriteResGroup10], (instrs LAHF, SAHF)>; // TODO: This doesn't match Agner's data
def: InstRW<[HWWriteResGroup10], (instregex "NOOP",
"SGDT64m",
@ -1958,4 +1958,6 @@ def HWWriteResGroup192 : SchedWriteRes<[HWPort0, HWPort5, HWPort06, HWPort15, HW
def: InstRW<[HWWriteResGroup192], (instrs VGATHERQPSrm,
VGATHERDPSrm)>;
def: InstRW<[WriteZero], (instrs CLC)>;
} // SchedModel

View File

@ -1144,4 +1144,6 @@ def SBWriteResGroup131 : SchedWriteRes<[SBPort0,SBPort1,SBPort23]> {
}
def: InstRW<[SBWriteResGroup131], (instregex "DIV(R?)_FI(16|32)m")>;
def: InstRW<[WriteZero], (instrs CLC)>;
} // SchedModel

View File

@ -584,7 +584,7 @@ def SKLWriteResGroup10 : SchedWriteRes<[SKLPort0156]> {
let ResourceCycles = [1];
}
def: InstRW<[SKLWriteResGroup10], (instrs CBW, CWDE, CDQE,
CLC, CMC, STC)>;
CMC, STC)>;
def: InstRW<[SKLWriteResGroup10], (instrs LAHF, SAHF)>; // TODO: This doesn't match Agner's data
def: InstRW<[SKLWriteResGroup10], (instregex "NOOP",
"SGDT64m",
@ -1839,4 +1839,6 @@ def SKLWriteResGroup223 : SchedWriteRes<[SKLPort0,SKLPort1,SKLPort4,SKLPort5,SKL
}
def: InstRW<[SKLWriteResGroup223], (instrs FSTENVm)>;
def: InstRW<[WriteZero], (instrs CLC)>;
} // SchedModel

View File

@ -606,7 +606,7 @@ def SKXWriteResGroup10 : SchedWriteRes<[SKXPort0156]> {
let ResourceCycles = [1];
}
def: InstRW<[SKXWriteResGroup10], (instrs CBW, CWDE, CDQE,
CLC, CMC, STC)>;
CMC, STC)>;
def: InstRW<[SKXWriteResGroup10], (instrs LAHF, SAHF)>; // TODO: This doesn't match Agner's data
def: InstRW<[SKXWriteResGroup10], (instregex "NOOP",
"SGDT64m",
@ -2550,4 +2550,7 @@ def SKXWriteResGroup267 : SchedWriteRes<[SKXPort6,SKXPort0156]> {
let ResourceCycles = [1,3];
}
def: InstRW<[SKXWriteResGroup267], (instrs PAUSE)>;
def: InstRW<[WriteZero], (instrs CLC)>;
} // SchedModel

View File

@ -3465,7 +3465,7 @@ define void @test_clc_cld_cmc() optsize {
; GENERIC-LABEL: test_clc_cld_cmc:
; GENERIC: # %bb.0:
; GENERIC-NEXT: #APP
; GENERIC-NEXT: clc # sched: [1:0.33]
; GENERIC-NEXT: clc # sched: [1:?]
; GENERIC-NEXT: cld # sched: [1:0.33]
; GENERIC-NEXT: cmc # sched: [1:0.33]
; GENERIC-NEXT: #NO_APP
@ -3492,7 +3492,7 @@ define void @test_clc_cld_cmc() optsize {
; SANDY-LABEL: test_clc_cld_cmc:
; SANDY: # %bb.0:
; SANDY-NEXT: #APP
; SANDY-NEXT: clc # sched: [1:0.33]
; SANDY-NEXT: clc # sched: [1:?]
; SANDY-NEXT: cld # sched: [1:0.33]
; SANDY-NEXT: cmc # sched: [1:0.33]
; SANDY-NEXT: #NO_APP
@ -3501,7 +3501,7 @@ define void @test_clc_cld_cmc() optsize {
; HASWELL-LABEL: test_clc_cld_cmc:
; HASWELL: # %bb.0:
; HASWELL-NEXT: #APP
; HASWELL-NEXT: clc # sched: [1:0.25]
; HASWELL-NEXT: clc # sched: [1:?]
; HASWELL-NEXT: cld # sched: [3:1.00]
; HASWELL-NEXT: cmc # sched: [1:0.25]
; HASWELL-NEXT: #NO_APP
@ -3510,7 +3510,7 @@ define void @test_clc_cld_cmc() optsize {
; BROADWELL-LABEL: test_clc_cld_cmc:
; BROADWELL: # %bb.0:
; BROADWELL-NEXT: #APP
; BROADWELL-NEXT: clc # sched: [1:0.25]
; BROADWELL-NEXT: clc # sched: [1:?]
; BROADWELL-NEXT: cld # sched: [3:1.00]
; BROADWELL-NEXT: cmc # sched: [1:0.25]
; BROADWELL-NEXT: #NO_APP
@ -3519,7 +3519,7 @@ define void @test_clc_cld_cmc() optsize {
; SKYLAKE-LABEL: test_clc_cld_cmc:
; SKYLAKE: # %bb.0:
; SKYLAKE-NEXT: #APP
; SKYLAKE-NEXT: clc # sched: [1:0.25]
; SKYLAKE-NEXT: clc # sched: [1:?]
; SKYLAKE-NEXT: cld # sched: [3:1.00]
; SKYLAKE-NEXT: cmc # sched: [1:0.25]
; SKYLAKE-NEXT: #NO_APP
@ -3528,7 +3528,7 @@ define void @test_clc_cld_cmc() optsize {
; SKX-LABEL: test_clc_cld_cmc:
; SKX: # %bb.0:
; SKX-NEXT: #APP
; SKX-NEXT: clc # sched: [1:0.25]
; SKX-NEXT: clc # sched: [1:?]
; SKX-NEXT: cld # sched: [3:1.00]
; SKX-NEXT: cmc # sched: [1:0.25]
; SKX-NEXT: #NO_APP

View File

@ -154,6 +154,8 @@ btcq $7, (%rax)
btrq $7, (%rax)
btsq $7, (%rax)
clc
decb %dil
decb (%rax)
decw %di
@ -745,6 +747,7 @@ xorq (%rax), %rdi
# CHECK-NEXT: 1 2 1.00 * * btcq $7, (%rax)
# CHECK-NEXT: 1 2 1.00 * * btrq $7, (%rax)
# CHECK-NEXT: 1 2 1.00 * * btsq $7, (%rax)
# CHECK-NEXT: 1 1 0.50 * clc
# CHECK-NEXT: 1 1 0.50 decb %dil
# CHECK-NEXT: 1 1 1.00 * * decb (%rax)
# CHECK-NEXT: 1 1 0.50 decw %di
@ -1153,7 +1156,7 @@ xorq (%rax), %rdi
# CHECK: Resource pressure per iteration:
# CHECK-NEXT: [0] [1]
# CHECK-NEXT: 1258.00 963.00
# CHECK-NEXT: 1258.50 963.50
# CHECK: Resource pressure by instruction:
# CHECK-NEXT: [0] [1] Instructions:
@ -1295,6 +1298,7 @@ xorq (%rax), %rdi
# CHECK-NEXT: 1.00 1.00 btcq $7, (%rax)
# CHECK-NEXT: 1.00 1.00 btrq $7, (%rax)
# CHECK-NEXT: 1.00 1.00 btsq $7, (%rax)
# CHECK-NEXT: 0.50 0.50 clc
# CHECK-NEXT: 0.50 0.50 decb %dil
# CHECK-NEXT: 1.00 - decb (%rax)
# CHECK-NEXT: 0.50 0.50 decw %di

View File

@ -154,6 +154,8 @@ btcq $7, (%rax)
btrq $7, (%rax)
btsq $7, (%rax)
clc
decb %dil
decb (%rax)
decw %di
@ -745,6 +747,7 @@ xorq (%rax), %rdi
# CHECK-NEXT: 4 6 1.00 * * btcq $7, (%rax)
# CHECK-NEXT: 4 6 1.00 * * btrq $7, (%rax)
# CHECK-NEXT: 4 6 1.00 * * btsq $7, (%rax)
# CHECK-NEXT: 1 1 - * clc
# CHECK-NEXT: 1 1 0.25 decb %dil
# CHECK-NEXT: 3 7 1.00 * * decb (%rax)
# CHECK-NEXT: 1 1 0.25 decw %di
@ -1303,6 +1306,7 @@ xorq (%rax), %rdi
# CHECK-NEXT: - - 0.50 - 0.83 0.83 1.00 - 0.50 0.33 btcq $7, (%rax)
# CHECK-NEXT: - - 0.50 - 0.83 0.83 1.00 - 0.50 0.33 btrq $7, (%rax)
# CHECK-NEXT: - - 0.50 - 0.83 0.83 1.00 - 0.50 0.33 btsq $7, (%rax)
# CHECK-NEXT: - - - - - - - - - - clc
# CHECK-NEXT: - - 0.25 0.25 - - - 0.25 0.25 - decb %dil
# CHECK-NEXT: - - 0.25 0.25 0.83 0.83 1.00 0.25 0.25 0.33 decb (%rax)
# CHECK-NEXT: - - 0.25 0.25 - - - 0.25 0.25 - decw %di

View File

@ -154,6 +154,8 @@ btcq $7, (%rax)
btrq $7, (%rax)
btsq $7, (%rax)
clc
decb %dil
decb (%rax)
decw %di
@ -745,6 +747,7 @@ xorq (%rax), %rdi
# CHECK-NEXT: 2 4 1.00 * * btcq $7, (%rax)
# CHECK-NEXT: 2 4 1.00 * * btrq $7, (%rax)
# CHECK-NEXT: 2 4 1.00 * * btsq $7, (%rax)
# CHECK-NEXT: 1 1 0.50 * clc
# CHECK-NEXT: 1 1 0.50 decb %dil
# CHECK-NEXT: 2 5 1.00 * * decb (%rax)
# CHECK-NEXT: 1 1 0.50 decw %di
@ -1165,7 +1168,7 @@ xorq (%rax), %rdi
# CHECK: Resource pressure per iteration:
# CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]
# CHECK-NEXT: 436.50 486.50 380.00 - - - - 263.00 64.00 195.00 - - - -
# CHECK-NEXT: 437.00 487.00 380.00 - - - - 263.00 64.00 195.00 - - - -
# CHECK: Resource pressure by instruction:
# CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] Instructions:
@ -1307,6 +1310,7 @@ xorq (%rax), %rdi
# CHECK-NEXT: 0.50 0.50 - - - - - 1.00 - 1.00 - - - - btcq $7, (%rax)
# CHECK-NEXT: 0.50 0.50 - - - - - 1.00 - 1.00 - - - - btrq $7, (%rax)
# CHECK-NEXT: 0.50 0.50 - - - - - 1.00 - 1.00 - - - - btsq $7, (%rax)
# CHECK-NEXT: 0.50 0.50 - - - - - - - - - - - - clc
# CHECK-NEXT: 0.50 0.50 - - - - - - - - - - - - decb %dil
# CHECK-NEXT: 0.50 0.50 - - - - - 1.00 - 1.00 - - - - decb (%rax)
# CHECK-NEXT: 0.50 0.50 - - - - - - - - - - - - decw %di

View File

@ -154,6 +154,8 @@ btcq $7, (%rax)
btrq $7, (%rax)
btsq $7, (%rax)
clc
decb %dil
decb (%rax)
decw %di
@ -745,6 +747,7 @@ xorq (%rax), %rdi
# CHECK-NEXT: 4 7 1.00 * * btcq $7, (%rax)
# CHECK-NEXT: 4 7 1.00 * * btrq $7, (%rax)
# CHECK-NEXT: 4 7 1.00 * * btsq $7, (%rax)
# CHECK-NEXT: 1 1 - * clc
# CHECK-NEXT: 1 1 0.25 decb %dil
# CHECK-NEXT: 3 7 1.00 * * decb (%rax)
# CHECK-NEXT: 1 1 0.25 decw %di
@ -1303,6 +1306,7 @@ xorq (%rax), %rdi
# CHECK-NEXT: - - 0.50 - 0.83 0.83 1.00 - 0.50 0.33 btcq $7, (%rax)
# CHECK-NEXT: - - 0.50 - 0.83 0.83 1.00 - 0.50 0.33 btrq $7, (%rax)
# CHECK-NEXT: - - 0.50 - 0.83 0.83 1.00 - 0.50 0.33 btsq $7, (%rax)
# CHECK-NEXT: - - - - - - - - - - clc
# CHECK-NEXT: - - 0.25 0.25 - - - 0.25 0.25 - decb %dil
# CHECK-NEXT: - - 0.25 0.25 0.83 0.83 1.00 0.25 0.25 0.33 decb (%rax)
# CHECK-NEXT: - - 0.25 0.25 - - - 0.25 0.25 - decw %di

View File

@ -154,6 +154,8 @@ btcq $7, (%rax)
btrq $7, (%rax)
btsq $7, (%rax)
clc
decb %dil
decb (%rax)
decw %di
@ -745,6 +747,7 @@ xorq (%rax), %rdi
# CHECK-NEXT: 2 4 2.00 * * btcq $7, (%rax)
# CHECK-NEXT: 2 4 2.00 * * btrq $7, (%rax)
# CHECK-NEXT: 2 4 2.00 * * btsq $7, (%rax)
# CHECK-NEXT: 1 1 0.50 * clc
# CHECK-NEXT: 1 1 0.50 decb %dil
# CHECK-NEXT: 2 5 2.00 * * decb (%rax)
# CHECK-NEXT: 1 1 0.50 decw %di
@ -1159,7 +1162,7 @@ xorq (%rax), %rdi
# CHECK: Resource pressure per iteration:
# CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7]
# CHECK-NEXT: 400.00 - - - - 391.50 233.50 470.00
# CHECK-NEXT: 400.00 - - - - 392.00 234.00 470.00
# CHECK: Resource pressure by instruction:
# CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] Instructions:
@ -1301,6 +1304,7 @@ xorq (%rax), %rdi
# CHECK-NEXT: - - - - - 0.50 0.50 2.00 btcq $7, (%rax)
# CHECK-NEXT: - - - - - 0.50 0.50 2.00 btrq $7, (%rax)
# CHECK-NEXT: - - - - - 0.50 0.50 2.00 btsq $7, (%rax)
# CHECK-NEXT: - - - - - 0.50 0.50 - clc
# CHECK-NEXT: - - - - - 0.50 0.50 - decb %dil
# CHECK-NEXT: - - - - - 1.00 1.00 2.00 decb (%rax)
# CHECK-NEXT: - - - - - 0.50 0.50 - decw %di

View File

@ -154,6 +154,8 @@ btcq $7, (%rax)
btrq $7, (%rax)
btsq $7, (%rax)
clc
decb %dil
decb (%rax)
decw %di
@ -745,6 +747,7 @@ xorq (%rax), %rdi
# CHECK-NEXT: 4 7 1.00 * * btcq $7, (%rax)
# CHECK-NEXT: 4 7 1.00 * * btrq $7, (%rax)
# CHECK-NEXT: 4 7 1.00 * * btsq $7, (%rax)
# CHECK-NEXT: 1 1 - * clc
# CHECK-NEXT: 1 1 0.33 decb %dil
# CHECK-NEXT: 3 7 1.00 * * decb (%rax)
# CHECK-NEXT: 1 1 0.33 decw %di
@ -1301,6 +1304,7 @@ xorq (%rax), %rdi
# CHECK-NEXT: - - 0.50 - 1.00 0.50 1.00 1.00 btcq $7, (%rax)
# CHECK-NEXT: - - 0.50 - 1.00 0.50 1.00 1.00 btrq $7, (%rax)
# CHECK-NEXT: - - 0.50 - 1.00 0.50 1.00 1.00 btsq $7, (%rax)
# CHECK-NEXT: - - - - - - - - clc
# CHECK-NEXT: - - 0.33 0.33 - 0.33 - - decb %dil
# CHECK-NEXT: - - 0.33 0.33 1.00 0.33 1.00 1.00 decb (%rax)
# CHECK-NEXT: - - 0.33 0.33 - 0.33 - - decw %di

View File

@ -154,6 +154,8 @@ btcq $7, (%rax)
btrq $7, (%rax)
btsq $7, (%rax)
clc
decb %dil
decb (%rax)
decw %di
@ -745,6 +747,7 @@ xorq (%rax), %rdi
# CHECK-NEXT: 4 6 1.00 * * btcq $7, (%rax)
# CHECK-NEXT: 4 6 1.00 * * btrq $7, (%rax)
# CHECK-NEXT: 4 6 1.00 * * btsq $7, (%rax)
# CHECK-NEXT: 1 1 - * clc
# CHECK-NEXT: 1 1 0.25 decb %dil
# CHECK-NEXT: 3 7 1.00 * * decb (%rax)
# CHECK-NEXT: 1 1 0.25 decw %di
@ -1303,6 +1306,7 @@ xorq (%rax), %rdi
# CHECK-NEXT: - - 0.50 - 0.83 0.83 1.00 - 0.50 0.33 btcq $7, (%rax)
# CHECK-NEXT: - - 0.50 - 0.83 0.83 1.00 - 0.50 0.33 btrq $7, (%rax)
# CHECK-NEXT: - - 0.50 - 0.83 0.83 1.00 - 0.50 0.33 btsq $7, (%rax)
# CHECK-NEXT: - - - - - - - - - - clc
# CHECK-NEXT: - - 0.25 0.25 - - - 0.25 0.25 - decb %dil
# CHECK-NEXT: - - 0.25 0.25 0.83 0.83 1.00 0.25 0.25 0.33 decb (%rax)
# CHECK-NEXT: - - 0.25 0.25 - - - 0.25 0.25 - decw %di

View File

@ -154,6 +154,8 @@ btcq $7, (%rax)
btrq $7, (%rax)
btsq $7, (%rax)
clc
decb %dil
decb (%rax)
decw %di
@ -745,6 +747,7 @@ xorq (%rax), %rdi
# CHECK-NEXT: 4 6 1.00 * * btcq $7, (%rax)
# CHECK-NEXT: 4 6 1.00 * * btrq $7, (%rax)
# CHECK-NEXT: 4 6 1.00 * * btsq $7, (%rax)
# CHECK-NEXT: 1 1 - * clc
# CHECK-NEXT: 1 1 0.25 decb %dil
# CHECK-NEXT: 3 7 1.00 * * decb (%rax)
# CHECK-NEXT: 1 1 0.25 decw %di
@ -1303,6 +1306,7 @@ xorq (%rax), %rdi
# CHECK-NEXT: - - 0.50 - 0.83 0.83 1.00 - 0.50 0.33 btcq $7, (%rax)
# CHECK-NEXT: - - 0.50 - 0.83 0.83 1.00 - 0.50 0.33 btrq $7, (%rax)
# CHECK-NEXT: - - 0.50 - 0.83 0.83 1.00 - 0.50 0.33 btsq $7, (%rax)
# CHECK-NEXT: - - - - - - - - - - clc
# CHECK-NEXT: - - 0.25 0.25 - - - 0.25 0.25 - decb %dil
# CHECK-NEXT: - - 0.25 0.25 0.83 0.83 1.00 0.25 0.25 0.33 decb (%rax)
# CHECK-NEXT: - - 0.25 0.25 - - - 0.25 0.25 - decw %di

View File

@ -154,6 +154,8 @@ btcq $7, (%rax)
btrq $7, (%rax)
btsq $7, (%rax)
clc
decb %dil
decb (%rax)
decw %di
@ -745,6 +747,7 @@ xorq (%rax), %rdi
# CHECK-NEXT: 2 6 0.50 * * btcq $7, (%rax)
# CHECK-NEXT: 2 6 0.50 * * btrq $7, (%rax)
# CHECK-NEXT: 2 6 0.50 * * btsq $7, (%rax)
# CHECK-NEXT: 1 1 0.25 * clc
# CHECK-NEXT: 1 1 0.25 decb %dil
# CHECK-NEXT: 2 5 0.50 * * decb (%rax)
# CHECK-NEXT: 1 1 0.25 decw %di
@ -1163,7 +1166,7 @@ xorq (%rax), %rdi
# CHECK: Resource pressure per iteration:
# CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]
# CHECK-NEXT: 131.50 131.50 111.50 145.50 127.50 111.50 392.00 - - - - 34.00
# CHECK-NEXT: 131.50 131.50 111.75 145.75 127.75 111.75 392.00 - - - - 34.00
# CHECK: Resource pressure by instruction:
# CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] Instructions:
@ -1305,6 +1308,7 @@ xorq (%rax), %rdi
# CHECK-NEXT: 0.50 0.50 0.25 0.25 0.25 0.25 - - - - - - btcq $7, (%rax)
# CHECK-NEXT: 0.50 0.50 0.25 0.25 0.25 0.25 - - - - - - btrq $7, (%rax)
# CHECK-NEXT: 0.50 0.50 0.25 0.25 0.25 0.25 - - - - - - btsq $7, (%rax)
# CHECK-NEXT: - - 0.25 0.25 0.25 0.25 - - - - - - clc
# CHECK-NEXT: - - 0.25 0.25 0.25 0.25 - - - - - - decb %dil
# CHECK-NEXT: 0.50 0.50 0.25 0.25 0.25 0.25 - - - - - - decb (%rax)
# CHECK-NEXT: - - 0.25 0.25 0.25 0.25 - - - - - - decw %di