Added optimizations for combining conditions together when their results are OR'ed

Added recognition of impossible comparisons via NZM and optimize them away
Recognize (x + -y) and transform to (x - y) for constants
Recognize (~x ) + 1 and transform to -x
Check and transform comparisons if theyre semantically equal to others
Detect comparisons of single-bit values with their only possible non-zero value and transform to true/false tests
Transform ==0 to IS_FALSE, !=0 to IS_TRUE
Truncate to int8 if operand for IS_TRUE/IS_FALSE has a nzm of 1
Reduced code generated for SubDidCarry slightly
Add special case for InstrEmit_srawix if mask == 1
Cut down the code generated for trap instructions, instead of naive or'ing or compare results do a switch and select the best condition
Rerun simplification pass until no changes, as some optimizations will enable others to be done
Enable rel32 call optimization by default
This commit is contained in:
chss95cs@gmail.com
2022-06-26 12:49:04 -07:00
parent e6898fda66
commit 3c06921cd4
8 changed files with 468 additions and 46 deletions

View File

@@ -21,6 +21,11 @@ DECLARE_bool(debug);
DEFINE_bool(store_all_context_values, false,
"Don't strip dead context stores to aid in debugging.", "CPU");
DEFINE_bool(full_optimization_even_with_debug, false,
"For developer use to analyze the quality of the generated code, "
"not intended for actual debugging of the code",
"CPU");
namespace xe {
namespace cpu {
namespace compiler {
@@ -77,7 +82,8 @@ bool ContextPromotionPass::Run(HIRBuilder* builder) {
// Remove all dead stores.
// This will break debugging as we can't recover this information when
// trying to extract stack traces/register values, so we don't do that.
if (!cvars::debug && !cvars::store_all_context_values) {
if (cvars::full_optimization_even_with_debug ||
(!cvars::debug && !cvars::store_all_context_values)) {
block = builder->first_block();
while (block) {
RemoveDeadStoresBlock(block);