Skip to content

Commit

Permalink
Remove now useless equation optimization.
Browse files Browse the repository at this point in the history
Checked with some performance benchmarks. These optimizations were necessary
with the previous new solver to optimize the order of the equations, but it
does not seem to have any major impact with the newer one.
  • Loading branch information
Roldak committed Oct 2, 2023
1 parent a4c3300 commit da12273
Showing 1 changed file with 3 additions and 59 deletions.
62 changes: 3 additions & 59 deletions ada/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -6231,40 +6231,6 @@ def derefed_base_subtype():
).base_subtype
)

@langkit_property(return_type=Bool)
def one_non_universal(second=T.BaseTypeDecl.entity):
return Or(
Not(Entity.is_null) & Entity.is_not_universal_type,
Not(second.is_null) & second.is_not_universal_type
)

@langkit_property(return_type=T.BaseTypeDecl.entity,
dynamic_vars=[default_origin()])
def non_universal_base_subtype(second=T.BaseTypeDecl.entity):
first_ok = Var(Not(Entity.is_null) & Entity.is_not_universal_type)
second_ok = Var(Not(second.is_null) & second.is_not_universal_type)
return Cond(
first_ok & second_ok,
Let(
lambda
first_st=Entity.derefed_base_subtype,
second_st=second.derefed_base_subtype:
If(
second_st.matching_formal_type(first_st),
first_st,
second_st
)
),

first_ok,
Entity.derefed_base_subtype,

second_ok,
second.derefed_base_subtype,

No(BaseTypeDecl.entity)
)

@langkit_property(return_type=T.BaseTypeDecl.entity,
dynamic_vars=[default_origin()])
def array_concat_result_type(other=T.BaseTypeDecl.entity):
Expand Down Expand Up @@ -13187,31 +13153,9 @@ def infer_from_either_operands(dest_var=T.LogicVar):
numeric types and arithmetic operators with the following profile:
``function "op" (X, Y : T) return T`` (we want to infer ``T``).
"""
left_ctx_free = Var(Self.left.has_context_free_type)
right_ctx_free = Var(Self.right.has_context_free_type)
return If(
# If both operands have a context free type, we can use an
# N-Propagate equation to assign `dest_var` because we know for
# sure that Self.left.type_var and Self.right.type_var will be
# given a value explicitly.
left_ctx_free & right_ctx_free,

Predicate(BaseTypeDecl.one_non_universal,
Self.left.type_var, Self.right.type_var)
& NPropagate(dest_var,
BaseTypeDecl.non_universal_base_subtype,
Self.left.type_var, Self.right.type_var),

Let(
lambda
infer_left=Entity.infer_from_left_operand(dest_var),
infer_right=Entity.infer_from_right_operand(dest_var):

If(left_ctx_free,
infer_left | infer_right,
infer_right | infer_left)
)
)
infer_left = Var(Entity.infer_from_left_operand(dest_var))
infer_right = Var(Entity.infer_from_right_operand(dest_var))
return infer_left | infer_right

@langkit_property()
def potential_actuals_for_dispatch(spec=T.BaseSubpSpec.entity):
Expand Down

0 comments on commit da12273

Please sign in to comment.