-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Experimental] PPU LLVM: Recycle identical functions #15308
base: master
Are you sure you want to change the base?
Conversation
Who wants to test MGS4 compilation time and link time (Applying PPU code)? |
rpcs3/Emu/Cell/PPUThread.cpp
Outdated
@@ -3845,6 +3850,154 @@ extern void ppu_precompile(std::vector<std::string>& dir_queue, std::vector<ppu_ | |||
} | |||
} | |||
} | |||
|
|||
if (file_queue.size() > old_size && file_queue.size() - 1 > old_size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (file_queue.size() > old_size && file_queue.size() - 1 > old_size) | |
if (file_queue.size() > old_size + 1) |
rpcs3/Emu/Cell/PPUThread.cpp
Outdated
for (auto& [name, key] : s_ch_to_lang) | ||
{ | ||
if (key == g_cfg.sys.language) | ||
{ | ||
chosen_lang = name; | ||
break; | ||
} | ||
} | ||
|
||
if (g_cfg.sys.language == CELL_SYSUTIL_LANG_ENGLISH_GB) | ||
{ | ||
// Fallback | ||
chosen_lang = "us"sv; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (auto& [name, key] : s_ch_to_lang) | |
{ | |
if (key == g_cfg.sys.language) | |
{ | |
chosen_lang = name; | |
break; | |
} | |
} | |
if (g_cfg.sys.language == CELL_SYSUTIL_LANG_ENGLISH_GB) | |
{ | |
// Fallback | |
chosen_lang = "us"sv; | |
} | |
const s32 language = g_cfg.sys.language == CELL_SYSUTIL_LANG_ENGLISH_GB ? CELL_SYSUTIL_LANG_ENGLISH_US : g_cfg.sys.language; | |
for (auto& [name, key] : s_ch_to_lang) | |
{ | |
if (key == language) | |
{ | |
chosen_lang = name; | |
break; | |
} | |
} |
rpcs3/Emu/Cell/PPUThread.cpp
Outdated
|
||
if (chosen_lang.empty()) | ||
{ | ||
// Disable optimization if other langues are selected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Disable optimization if other langues are selected | |
// Disable optimization if other languages are selected |
rpcs3/Emu/Cell/PPUThread.cpp
Outdated
{ | ||
prev_fname = std::move(fname); | ||
} | ||
else if (!prev_fname.empty() && prev_fname.size() == fname.size()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else if (!prev_fname.empty() && prev_fname.size() == fname.size()) | |
else if (prev_fname.size() == fname.size()) |
rpcs3/Emu/Cell/PPUThread.cpp
Outdated
const std::string_view plang = std::string_view(prev_fname).substr(j, 2); | ||
const std::string_view flang = std::string_view(fname).substr(j, 2); | ||
|
||
if (plang != flang && s_ch_to_lang.count(plang) && s_ch_to_lang.count(flang)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (plang != flang && s_ch_to_lang.count(plang) && s_ch_to_lang.count(flang)) | |
if (plang != flang && s_ch_to_lang.contains(plang) && s_ch_to_lang.contains(flang)) |
rpcs3/Emu/Cell/PPUThread.cpp
Outdated
|
||
const std::string_view flang = std::string_view(fname).substr(j, 2); | ||
|
||
if (s_ch_to_lang.count(flang) && chosen_lang != flang) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (s_ch_to_lang.count(flang) && chosen_lang != flang) | |
if (s_ch_to_lang.contains(flang) && chosen_lang != flang) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
rpcs3/Emu/Cell/PPUThread.cpp
Outdated
@@ -3854,6 +4007,15 @@ extern void ppu_precompile(std::vector<std::string>& dir_queue, std::vector<ppu_ | |||
for (const file_info& info : file_queue) | |||
{ | |||
total_files_size += info.file_size; | |||
|
|||
if (!info.rec_name.empty()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kinda weird to take the negated path first.
rpcs3/Emu/Cell/PPUThread.cpp
Outdated
usz j = 0; | ||
|
||
for (; j < fname.size() - 7; j++) | ||
{ | ||
if (prev_fname[j] != fname[j]) | ||
{ | ||
break; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this the same as
const usz j = prev_fname[j].find_first_not_of(fname[j]);
?
rpcs3/Emu/Cell/PPUThread.cpp
Outdated
if (fname.ends_with(".self")) | ||
{ | ||
if (prev_fname.size() == fname.size()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would probably be faster the other way around
a8edced
to
4a8a58c
Compare
@elad335 My Compile FW FULL SPEED 14600KF Thanks Brow !!!!! |
Failed to boot Guitar Hero 5 Log: |
15295c2
to
b1c7f88
Compare
Failed to boot gt6 |
Test all games Bug Boot |
I noticed that more then 40% of functions examined in some executables, occur more than once throughout the executable. So, why not reuse their code when possible in order to reduce compilation and link time?
There are some exceptions, not all identical functions are truly identical in meaning if they are located elsewhere so I also check if they contain any relative branch that tragets external code. (which changes the meaning of the function)
Edit: because of the spectacular bugs I created when debugging this PR, I discovered a bug in sys_prx_stop_module that is fixed here. (turns it it can abort an ongoing starting process of PRX)