mirror of
https://github.com/open-goal/jak-project
synced 2026-07-11 15:28:58 -04:00
more fixes
This commit is contained in:
@@ -1089,6 +1089,26 @@ void SimpleExpressionElement::update_from_stack_float_2_nestable(const Env& env,
|
||||
bool allow_side_effects) {
|
||||
if (is_float_type(env, m_my_idx, m_expr.get_arg(0).var()) &&
|
||||
is_float_type(env, m_my_idx, m_expr.get_arg(1).var())) {
|
||||
if (m_expr.get_arg(0).var() == m_expr.get_arg(1).var()) {
|
||||
auto arg =
|
||||
pop_to_forms({m_expr.get_arg(0).var()}, env, pool, stack, allow_side_effects, {}, {2})
|
||||
.at(0);
|
||||
if (kind == FixedOperatorKind::MULTIPLICATION) {
|
||||
result->push_back(pool.alloc_element<GenericElement>(
|
||||
GenericOperator::make_function(pool.form<ConstantTokenElement>("square")), arg));
|
||||
return;
|
||||
}
|
||||
|
||||
auto atom = form_as_atom(arg);
|
||||
if (atom) {
|
||||
auto arg_copy = pool.form<SimpleAtomElement>(*atom);
|
||||
auto new_form =
|
||||
make_and_compact_math_op(arg, arg_copy, {}, {}, pool, env, kind, true, false);
|
||||
result->push_back(new_form);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
auto args = pop_to_forms({m_expr.get_arg(0).var(), m_expr.get_arg(1).var()}, env, pool, stack,
|
||||
allow_side_effects);
|
||||
auto new_form =
|
||||
|
||||
@@ -305,6 +305,13 @@ bool Matcher::do_match(Form* input, MatchResult::Maps* maps_out, const Env* cons
|
||||
}
|
||||
}
|
||||
|
||||
auto as_stack_spill =
|
||||
dynamic_cast<StackSpillValueElement*>(input->try_as_single_active_element());
|
||||
if (as_stack_spill) {
|
||||
got = true;
|
||||
result = make_stack_slot_access(as_stack_spill->stack_offset());
|
||||
}
|
||||
|
||||
if (got) {
|
||||
if (m_kind == Kind::REG) {
|
||||
return result.reg() == *m_reg;
|
||||
|
||||
@@ -45,6 +45,7 @@ If the previous let variables appear in the definition of new one, make the let
|
||||
|
||||
namespace {
|
||||
FormElement* rewrite_let(LetElement* in, const Env& env, FormPool& pool, LetRewriteStats& stats);
|
||||
FormElement* rewrite_multi_let_as_vector_dot(LetElement* in, const Env& env, FormPool& pool);
|
||||
bool let_uses_stack_slot_access(const LetElement* in);
|
||||
|
||||
std::vector<Form*> path_up_tree(Form* in, const Env&) {
|
||||
@@ -2410,6 +2411,14 @@ FormElement* rewrite_set_font_single(LetElement* in,
|
||||
FormElement* rewrite_let(LetElement* in, const Env& env, FormPool& pool, LetRewriteStats& stats) {
|
||||
// ordered based on frequency. for best performance, you check the most likely rewrites first!
|
||||
|
||||
if (in->entries().size() >= 6) {
|
||||
auto as_vector_dot = rewrite_multi_let_as_vector_dot(in, env, pool);
|
||||
if (as_vector_dot) {
|
||||
stats.vector_dot++;
|
||||
return as_vector_dot;
|
||||
}
|
||||
}
|
||||
|
||||
if (let_uses_stack_slot_access(in)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -3078,6 +3087,14 @@ FormElement* rewrite_multi_let(LetElement* in,
|
||||
const Env& env,
|
||||
FormPool& pool,
|
||||
LetRewriteStats& stats) {
|
||||
if (in->entries().size() >= 6) {
|
||||
auto as_vector_dot = rewrite_multi_let_as_vector_dot(in, env, pool);
|
||||
if (as_vector_dot) {
|
||||
stats.vector_dot++;
|
||||
return as_vector_dot;
|
||||
}
|
||||
}
|
||||
|
||||
if (let_uses_stack_slot_access(in)) {
|
||||
return in;
|
||||
}
|
||||
@@ -3110,14 +3127,6 @@ FormElement* rewrite_multi_let(LetElement* in,
|
||||
}
|
||||
}
|
||||
|
||||
if (in->entries().size() >= 6) {
|
||||
auto as_vector_dot = rewrite_multi_let_as_vector_dot(in, env, pool);
|
||||
if (as_vector_dot) {
|
||||
stats.vector_dot++;
|
||||
return as_vector_dot;
|
||||
}
|
||||
}
|
||||
|
||||
auto as_font_set_origin = rewrite_set_font_origin(in, env, pool);
|
||||
if (as_font_set_origin) {
|
||||
stats.font_method++;
|
||||
|
||||
Reference in New Issue
Block a user