drastically reduce size of final generated code for rlwinm by adding special paths for rotations of 0, masks that discard the rotated bits and using And w/ UINT_MAX instead of truncate/zero extend
Add special case to TYPE_INT64's EmitAnd for UINT_MAX mask. Do mov32 to 32 if detected to take advantage of implicit zero xt/reg renaming Add helper function for skipping assignment defs in instr. Add helper function for checking if an opcode is binary value type Add several new optimizations to simplificationpass, plus weak NZM calculation code (better full evaluation of Z/NZ will be done later) . List of optimizations: If a value is anded with a bitmask that it was already masked against, reuse the old value (this cuts out most FPSCR update garbage, although it does cause a local variable to be allocated for the masked FPSCR and it still repeatedly stores the masked value to the context) If masking a value that was or'ed against another check whether our mask only considers bits from one value or another. if so, change the operand to the OR input that actually matters If the only usage of a rotate left's output is an AND against a mask that discards the bits that were rotated in change the opcode to SHIFT_LEFT If masking against all ones, become an assign. If XOR or OR against 0, become an assign (additional FPSCR codegen cleanup) If XOR against all ones, become a NOT Adding a direct CPUID check to x64_emitter for lzcnt, the version of xbyak we are using is skipping checking for lzcnt on all non-intel cpus, meaning we are generating the much slower bitscan path for AMD cpus.
This commit is contained in:
@@ -59,6 +59,52 @@ class Instr {
|
||||
void MoveBefore(Instr* other);
|
||||
void Replace(const OpcodeInfo* new_opcode, uint16_t new_flags);
|
||||
void Remove();
|
||||
|
||||
template <typename TPredicate>
|
||||
std::pair<Value*, Value*> BinaryValueArrangeByPredicateExclusive(
|
||||
TPredicate&& pred) {
|
||||
auto src1_value = src1.value;
|
||||
auto src2_value = src2.value;
|
||||
if (!src1_value || !src2_value) return {nullptr, nullptr};
|
||||
|
||||
if (!opcode) return {nullptr, nullptr}; // impossible!
|
||||
|
||||
// check if binary opcode taking two values. we dont care if the dest is a
|
||||
// value
|
||||
|
||||
if (!IsOpcodeBinaryValue(opcode->signature)) return {nullptr, nullptr};
|
||||
|
||||
if (pred(src1_value)) {
|
||||
if (pred(src2_value)) {
|
||||
return {nullptr, nullptr};
|
||||
} else {
|
||||
return {src1_value, src2_value};
|
||||
}
|
||||
} else if (pred(src2_value)) {
|
||||
return {src2_value, src1_value};
|
||||
} else {
|
||||
return {nullptr, nullptr};
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if src1 is constant, and src2 is not, return [src1, src2]
|
||||
if src2 is constant, and src1 is not, return [src2, src1]
|
||||
if neither is constant, return nullptr, nullptr
|
||||
if both are constant, return nullptr, nullptr
|
||||
*/
|
||||
std::pair<Value*, Value*> BinaryValueArrangeAsConstAndVar() {
|
||||
return BinaryValueArrangeByPredicateExclusive(
|
||||
[](Value* value) { return value->IsConstant(); });
|
||||
}
|
||||
std::pair<Value*, Value*> BinaryValueArrangeByDefiningOpcode(
|
||||
const OpcodeInfo* op_ptr) {
|
||||
return BinaryValueArrangeByPredicateExclusive([op_ptr](Value* value) {
|
||||
return value->def && value->def->opcode == op_ptr;
|
||||
});
|
||||
}
|
||||
|
||||
Instr* GetDestDefSkipAssigns();
|
||||
};
|
||||
|
||||
} // namespace hir
|
||||
|
||||
Reference in New Issue
Block a user