Skip to content

Commit

Permalink
Merge pull request #3989 from alyssarosenzweig/ici/x8count
Browse files Browse the repository at this point in the history
InstCountCI: include x86 instruction count
  • Loading branch information
alyssarosenzweig authored Aug 22, 2024
2 parents cfa2ad8 + d935d25 commit 50a9cea
Show file tree
Hide file tree
Showing 17 changed files with 118 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Scripts/UpdateInstructionCountJson.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
logger = logging.getLogger()
logger.setLevel(logging.ERROR)

def insert_before(d, key, item):
items = list(d.items())
items.insert(list(d.keys()).index(key), item)
return dict(items)

def update_performance_numbers(performance_json_path, performance_json, new_json_numbers):
for key, items in new_json_numbers.items():
if len(key) == 0:
Expand All @@ -18,6 +23,12 @@ def update_performance_numbers(performance_json_path, performance_json, new_json
performance_json["Instructions"][key]["ExpectedInstructionCount"] = items["ExpectedInstructionCount"]
if "ExpectedArm64ASM" in items:
performance_json["Instructions"][key]["ExpectedArm64ASM"] = items["ExpectedArm64ASM"]
if "x86Insts" in performance_json["Instructions"][key]:
d = performance_json["Instructions"][key]
d.pop('x86InstructionCount', None)
d = insert_before(d, "ExpectedInstructionCount",
("x86InstructionCount", len(d["x86Insts"])))
performance_json["Instructions"][key] = d

# Output to the original file.
with open(performance_json_path, "w") as json_file:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,7 @@
"mov rax, gs:0x100",
"mov rbx, gs:0x14"
],
"x86InstructionCount": 2,
"ExpectedInstructionCount": 4,
"ExpectedArm64ASM": [
"ldr x20, [x28, #960]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
"mov eax, gs:0x100",
"mov ebx, gs:0x14"
],
"x86InstructionCount": 2,
"ExpectedInstructionCount": 4,
"ExpectedArm64ASM": [
"ldr w20, [x28, #960]",
Expand Down
28 changes: 28 additions & 0 deletions unittests/InstructionCountCI/FEXOpt/MultiInst.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
],
"Instructions": {
"push ax, bx": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 2,
"Comment": [
"Mergable 16-bit pushes. May or may not be an optimization."
Expand All @@ -31,6 +32,7 @@
]
},
"push rax, rbx": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 2,
"Comment": [
"Mergable 64-bit pushes"
Expand All @@ -45,6 +47,7 @@
]
},
"adds xmm0, xmm1, xmm2": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 4,
"Comment": [
"Redundant scalar adds that can get eliminated without AFP."
Expand All @@ -61,6 +64,7 @@
]
},
"positive movsb": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 6,
"Comment": [
"When direction flag is a compile time constant we can optimize",
Expand All @@ -80,6 +84,7 @@
]
},
"positive movsw": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 6,
"Comment": [
"When direction flag is a compile time constant we can optimize",
Expand All @@ -99,6 +104,7 @@
]
},
"positive movsd": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 6,
"Comment": [
"When direction flag is a compile time constant we can optimize",
Expand All @@ -118,6 +124,7 @@
]
},
"positive movsq": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 6,
"Comment": [
"When direction flag is a compile time constant we can optimize",
Expand All @@ -137,6 +144,7 @@
]
},
"negative movsb": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 6,
"Comment": [
"When direction flag is a compile time constant we can optimize",
Expand All @@ -156,6 +164,7 @@
]
},
"negative movsw": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 6,
"Comment": [
"When direction flag is a compile time constant we can optimize",
Expand All @@ -175,6 +184,7 @@
]
},
"negative movsd": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 6,
"Comment": [
"When direction flag is a compile time constant we can optimize",
Expand All @@ -194,6 +204,7 @@
]
},
"negative movsq": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 6,
"Comment": [
"When direction flag is a compile time constant we can optimize",
Expand All @@ -213,6 +224,7 @@
]
},
"positive rep movsb": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 44,
"Comment": [
"When direction flag is a compile time constant we can optimize",
Expand Down Expand Up @@ -270,6 +282,7 @@
]
},
"positive rep movsw": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 44,
"Comment": [
"When direction flag is a compile time constant we can optimize",
Expand Down Expand Up @@ -327,6 +340,7 @@
]
},
"positive rep movsd": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 44,
"Comment": [
"When direction flag is a compile time constant we can optimize",
Expand Down Expand Up @@ -384,6 +398,7 @@
]
},
"positive rep movsq": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 44,
"Comment": [
"When direction flag is a compile time constant we can optimize",
Expand Down Expand Up @@ -441,6 +456,7 @@
]
},
"negative rep movsb": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 47,
"Comment": [
"When direction flag is a compile time constant we can optimize",
Expand Down Expand Up @@ -501,6 +517,7 @@
]
},
"negative rep movsw": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 47,
"Comment": [
"When direction flag is a compile time constant we can optimize",
Expand Down Expand Up @@ -561,6 +578,7 @@
]
},
"negative rep movsd": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 47,
"Comment": [
"When direction flag is a compile time constant we can optimize",
Expand Down Expand Up @@ -621,6 +639,7 @@
]
},
"negative rep movsq": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 47,
"Comment": [
"When direction flag is a compile time constant we can optimize",
Expand Down Expand Up @@ -681,6 +700,7 @@
]
},
"positive rep stosb": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 30,
"Comment": [
"When direction flag is a compile time constant we can optimize",
Expand Down Expand Up @@ -724,6 +744,7 @@
]
},
"positive rep stosw": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 30,
"Comment": [
"When direction flag is a compile time constant we can optimize",
Expand Down Expand Up @@ -767,6 +788,7 @@
]
},
"positive rep stosd": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 30,
"Comment": [
"When direction flag is a compile time constant we can optimize",
Expand Down Expand Up @@ -810,6 +832,7 @@
]
},
"positive rep stosq": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 29,
"Comment": [
"When direction flag is a compile time constant we can optimize",
Expand Down Expand Up @@ -852,6 +875,7 @@
]
},
"negative rep stosb": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 31,
"Comment": [
"When direction flag is a compile time constant we can optimize",
Expand Down Expand Up @@ -896,6 +920,7 @@
]
},
"negative rep stosw": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 31,
"Comment": [
"When direction flag is a compile time constant we can optimize",
Expand Down Expand Up @@ -940,6 +965,7 @@
]
},
"negative rep stosd": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 31,
"Comment": [
"When direction flag is a compile time constant we can optimize",
Expand Down Expand Up @@ -984,6 +1010,7 @@
]
},
"negative rep stosq": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 30,
"Comment": [
"When direction flag is a compile time constant we can optimize",
Expand Down Expand Up @@ -1027,6 +1054,7 @@
]
},
"Sekiro spill block": {
"x86InstructionCount": 119,
"ExpectedInstructionCount": 126,
"Comment": [
"This block of code came from the settings screen when it loaded",
Expand Down
1 change: 1 addition & 0 deletions unittests/InstructionCountCI/FEXOpt/MultiInst_AFP.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
],
"Instructions": {
"adds xmm0, xmm1, xmm2": {
"x86InstructionCount": 2,
"ExpectedInstructionCount": 2,
"Comment": [
"Redundant scalar operations should get eliminated with AFP"
Expand Down
1 change: 1 addition & 0 deletions unittests/InstructionCountCI/FEXOpt/libnss.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"Comment": [],
"Instructions": {
"libnss3 sha": {
"x86InstructionCount": 168,
"ExpectedInstructionCount": 2366,
"Comment": [
"This block of code comes from libnss3 which causes panic spilling in FEX's RA.",
Expand Down
Loading

0 comments on commit 50a9cea

Please sign in to comment.