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

@@ -66,7 +66,15 @@ inline uint64_t GetScalarTypeMask(TypeName type_name) {
return (1ULL << (mask_width * CHAR_BIT)) - 1;
}
}
static inline uint64_t GetScalarSignbitMask(TypeName type_name) {
size_t type_width = GetTypeSize(type_name);
return 1ULL << ((type_width * CHAR_BIT) - 1);
}
static inline bool IsScalarIntegralType(TypeName type_name) {
return type_name < FLOAT32_TYPE && type_name >= INT8_TYPE;
}
enum ValueFlags {
VALUE_IS_CONSTANT = (1 << 1),
VALUE_IS_ALLOCATED = (1 << 2), // Used by backends. Do not set.