Skip to content

Commit d1874d4

Browse files
authored
Merge pull request #302 from JuliaGPU/tb/1.8
Fixes for 1.8
2 parents 55ae222 + ceb0717 commit d1874d4

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
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

src/validation.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function Base.showerror(io::IO, err::InvalidIRError)
102102
Base.show_backtrace(io, bt)
103103
end
104104
println(io)
105-
printstyled(io, "HINT"; bold = true, color = :cyan)
105+
printstyled(io, "Hint"; bold = true, color = :cyan)
106106
printstyled(
107107
io,
108108
": catch this exception as `err` and call `code_typed(err; interactive = true)` to",

test/native.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ end
228228
native_code_execution(foobar, Tuple{Int})) do msg
229229
occursin("invalid LLVM IR", msg) &&
230230
(occursin(GPUCompiler.RUNTIME_FUNCTION, msg) ||
231-
occursin(GPUCompiler.UNKNOWN_FUNCTION, msg)) &&
231+
occursin(GPUCompiler.UNKNOWN_FUNCTION, msg) ||
232+
occursin(GPUCompiler.DYNAMIC_CALL, msg)) &&
232233
occursin("[1] println", msg) &&
233234
occursin(r"\[2\] .*foobar", msg)
234235
end
@@ -282,6 +283,10 @@ end
282283
end
283284
end
284285

286+
end
287+
288+
############################################################################################
289+
285290
@testset "LazyCodegen" begin
286291
import .LazyCodegen: call_delayed
287292

@@ -330,8 +335,6 @@ end
330335
@test call_delayed(complex, 1.0, 2.0) == 1.0+2.0im
331336
end
332337

333-
end
334-
335338
############################################################################################
336339

337340
@testset "overrides" begin

test/util.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## test helpers
22

3+
using Test
4+
35
# @test_throw, with additional testing for the exception message
46
macro test_throws_message(f, typ, ex...)
57
quote

0 commit comments

Comments
 (0)