Skip to content

Commit

Permalink
Optimization: Added support for refusing code generation for useless …
Browse files Browse the repository at this point in the history
…variants
  • Loading branch information
kayhayen committed May 14, 2019
1 parent bb29715 commit e231ad3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions nuitka/codegen/CodeHelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,9 @@ def withObjectCodeTemporaryAssignment(to_name, value_name, expression, emit, con
getReleaseCode(value_name, emit, context)


def pickCodeHelper(prefix, suffix, left_shape, right_shape, helpers, warn_missing=True):
def pickCodeHelper(
prefix, suffix, left_shape, right_shape, helpers, nonhelpers=(), warn_missing=True
):
left_part = left_shape.helper_code
right_part = right_shape.helper_code

Expand All @@ -291,7 +293,7 @@ def pickCodeHelper(prefix, suffix, left_shape, right_shape, helpers, warn_missin
if ideal_helper in helpers:
return ideal_helper

if warn_missing:
if warn_missing and ideal_helper not in nonhelpers:
onMissingHelper(ideal_helper)

fallback_helper = "%s_%s_%s%s" % (prefix, "OBJECT", "OBJECT", suffix)
Expand Down
5 changes: 5 additions & 0 deletions nuitka/codegen/OperationCodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ def generateOperationUnaryCode(to_name, expression, emit, context):
"BINARY_OPERATION_SUB_OBJECT_OBJECT",
)
)
# These made no sense to specialize for, nothing to gain.
nonspecialized_sub_helpers_set = set(
("BINARY_OPERATION_SUB_OBJECT_LIST", "BINARY_OPERATION_SUB_OBJECT_TUPLE")
)

specialized_mul_helpers_set = OrderedSet(
(
Expand Down Expand Up @@ -286,6 +290,7 @@ def _getBinaryOperationCode(
left_shape=left.getTypeShape(),
right_shape=expression.getRight().getTypeShape(),
helpers=specialized_sub_helpers_set,
nonhelpers=nonspecialized_sub_helpers_set,
)
elif operator == "IAdd" and in_place:
helper = pickCodeHelper(
Expand Down

0 comments on commit e231ad3

Please sign in to comment.