@@ -563,6 +563,12 @@ function lift_comparison!(::typeof(isdefined), compact::IncrementalCompact,
563
563
lift_comparison_leaves! (isdefined_tfunc, compact, val, cmp, lifting_cache, idx, πβ)
564
564
end
565
565
566
+ function phi_or_ifelse_predecessors (@nospecialize (def), compact:: IncrementalCompact )
567
+ isa (def, PhiNode) && return def. values
568
+ is_known_call (def, Core. ifelse, compact) && return def. args[3 : 4 ]
569
+ return nothing
570
+ end
571
+
566
572
function lift_comparison_leaves! (@specialize (tfunc),
567
573
compact:: IncrementalCompact , @nospecialize (val), @nospecialize (cmp),
568
574
lifting_cache:: IdDict{Pair{AnySSAValue, Any}, AnySSAValue} , idx:: Int ,
@@ -573,12 +579,8 @@ function lift_comparison_leaves!(@specialize(tfunc),
573
579
end
574
580
isa (typeconstraint, Union) || return # bail out if there won't be a good chance for lifting
575
581
576
- predecessors = function (@nospecialize (def), compact:: IncrementalCompact )
577
- isa (def, PhiNode) && return def. values
578
- is_known_call (def, Core. ifelse, compact) && return def. args[3 : 4 ]
579
- return nothing
580
- end
581
- leaves, visited_philikes = collect_leaves (compact, val, typeconstraint, πβ, predecessors)
582
+
583
+ leaves, visited_philikes = collect_leaves (compact, val, typeconstraint, πβ, phi_or_ifelse_predecessors)
582
584
length (leaves) β€ 1 && return # bail out if we don't have multiple leaves
583
585
584
586
# check if we can evaluate the comparison for each one of the leaves
@@ -1093,11 +1095,10 @@ function sroa_pass!(ir::IRCode, inlining::Union{Nothing,InliningState}=nothing)
1093
1095
end
1094
1096
1095
1097
# perform SROA on immutable structs here on
1096
-
1097
1098
field = try_compute_fieldidx_stmt (compact, stmt, struct_typ)
1098
1099
field === nothing && continue
1099
1100
1100
- leaves, visited_philikes = collect_leaves (compact, val, struct_typ, πβ)
1101
+ leaves, visited_philikes = collect_leaves (compact, val, struct_typ, πβ, phi_or_ifelse_predecessors )
1101
1102
isempty (leaves) && continue
1102
1103
1103
1104
lifted_result = lift_leaves (compact, field, leaves, πβ)
0 commit comments