@@ -91,7 +91,6 @@ function addOptimizationPasses!(pm, opt_level=2)
91
91
alloc_opt! (pm)
92
92
loop_rotate! (pm)
93
93
# moving IndVarSimplify here prevented removing the loop in perf_sumcartesian(10:-1:1)
94
- loop_idiom! (pm)
95
94
96
95
# LoopRotate strips metadata from terminator, so run LowerSIMD afterwards
97
96
lower_simdloop! (pm) # Annotate loop marked with "loopinfo" as LLVM parallel loop
@@ -103,6 +102,7 @@ function addOptimizationPasses!(pm, opt_level=2)
103
102
inductive_range_check_elimination! (pm)
104
103
# Subsequent passes not stripping metadata from terminator
105
104
instruction_simplify! (pm)
105
+ loop_idiom! (pm)
106
106
ind_var_simplify! (pm)
107
107
loop_deletion! (pm)
108
108
loop_unroll! (pm) # TODO : in Julia createSimpleLoopUnroll
@@ -119,13 +119,21 @@ function addOptimizationPasses!(pm, opt_level=2)
119
119
mem_cpy_opt! (pm)
120
120
sccp! (pm)
121
121
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
+
122
128
# Run instcombine after redundancy elimination to exploit opportunities
123
129
# opened up by them.
124
130
# This needs to be InstCombine instead of InstSimplify to allow
125
131
# loops over Union-typed arrays to vectorize.
126
132
instruction_combining! (pm)
127
133
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
129
137
dead_store_elimination! (pm)
130
138
131
139
# More dead allocation (store) deletion before loop optimization
@@ -140,13 +148,15 @@ function addOptimizationPasses!(pm, opt_level=2)
140
148
loop_vectorize! (pm)
141
149
loop_load_elimination! (pm)
142
150
# Cleanup after LV pass
151
+ instruction_combining! (pm)
143
152
if LLVM. version () >= v " 12"
144
153
cfgsimplification! (pm; # Aggressive CFG simplification
145
154
forward_switch_cond_to_phi= true ,
146
155
convert_switch_to_lookup_table= true ,
147
156
need_canonical_loop= true ,
148
157
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
+ )
150
160
else
151
161
cfgsimplification! (pm)
152
162
end
0 commit comments