Skip to content

Commit 77ec7ce

Browse files
committed
Align passes with Julia 1.8.
1 parent b6b6d8d commit 77ec7ce

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/optim.jl

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ function addOptimizationPasses!(pm, opt_level=2)
9191
alloc_opt!(pm)
9292
loop_rotate!(pm)
9393
# moving IndVarSimplify here prevented removing the loop in perf_sumcartesian(10:-1:1)
94-
loop_idiom!(pm)
9594

9695
# LoopRotate strips metadata from terminator, so run LowerSIMD afterwards
9796
lower_simdloop!(pm) # Annotate loop marked with "loopinfo" as LLVM parallel loop
@@ -103,6 +102,7 @@ function addOptimizationPasses!(pm, opt_level=2)
103102
inductive_range_check_elimination!(pm)
104103
# Subsequent passes not stripping metadata from terminator
105104
instruction_simplify!(pm)
105+
loop_idiom!(pm)
106106
ind_var_simplify!(pm)
107107
loop_deletion!(pm)
108108
loop_unroll!(pm) # TODO: in Julia createSimpleLoopUnroll
@@ -119,13 +119,21 @@ function addOptimizationPasses!(pm, opt_level=2)
119119
mem_cpy_opt!(pm)
120120
sccp!(pm)
121121

122+
# These next two passes must come before IRCE to eliminate the bounds check in #43308
123+
correlated_value_propagation!(pm)
124+
dce!(pm)
125+
126+
inductive_range_check_elimination!(pm) # Must come between the two GVN passes
127+
122128
# Run instcombine after redundancy elimination to exploit opportunities
123129
# opened up by them.
124130
# This needs to be InstCombine instead of InstSimplify to allow
125131
# loops over Union-typed arrays to vectorize.
126132
instruction_combining!(pm)
127133
jump_threading!(pm)
128-
correlated_value_propagation!(pm)
134+
if opt_level >= 3
135+
gvn!(pm) # Must come after JumpThreading and before LoopVectorize
136+
end
129137
dead_store_elimination!(pm)
130138

131139
# More dead allocation (store) deletion before loop optimization
@@ -140,13 +148,15 @@ function addOptimizationPasses!(pm, opt_level=2)
140148
loop_vectorize!(pm)
141149
loop_load_elimination!(pm)
142150
# Cleanup after LV pass
151+
instruction_combining!(pm)
143152
if LLVM.version() >= v"12"
144153
cfgsimplification!(pm; # Aggressive CFG simplification
145154
forward_switch_cond_to_phi=true,
146155
convert_switch_to_lookup_table=true,
147156
need_canonical_loop=true,
148157
hoist_common_insts=true,
149-
sink_common_insts=true) # FIXME: Causes assertion in llvm-late-lowering
158+
#sink_common_insts=true # FIXME: Causes assertion in llvm-late-lowering
159+
)
150160
else
151161
cfgsimplification!(pm)
152162
end

0 commit comments

Comments
 (0)