Skip to content

Commit 301b6b3

Browse files
authored
Add additional optimization passes. (#259)
1 parent a2e0b9a commit 301b6b3

File tree

4 files changed

+20
-14
lines changed

4 files changed

+20
-14
lines changed

Manifest.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ version = "1.3.0"
3939

4040
[[LLVM]]
4141
deps = ["CEnum", "LLVMExtra_jll", "Libdl", "Printf", "Unicode"]
42-
git-tree-sha1 = "46092047ca4edc10720ecab437c42283cd7c44f3"
42+
git-tree-sha1 = "7cc22e69995e2329cc047a879395b2b74647ab5f"
43+
repo-rev = "6998bf4"
44+
repo-url = "https://github.com/maleadt/LLVM.jl.git"
4345
uuid = "929cbde3-209d-540e-8aea-75f648917ca0"
44-
version = "4.6.0"
46+
version = "4.7.0"
4547

4648
[[LLVMExtra_jll]]
4749
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
1414

1515
[compat]
1616
ExprTools = "0.1"
17-
LLVM = "4.6"
17+
LLVM = "4.7"
1818
TimerOutputs = "0.5"
1919
julia = "1.6"
2020

src/optim.jl

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,6 @@ function addOptimizationPasses!(pm, opt_level=2)
1313
# pm, opt_level, #=lower_intrinsics=# 0)
1414
#return
1515

16-
# compate to Clang by using the pass manager builder APIs:
17-
#LLVM.clopts("-print-after-all", "-filter-print-funcs=$(LLVM.name(entry))")
18-
#ModulePassManager() do pm
19-
# add_library_info!(pm, triple(mod))
20-
# add_transform_info!(pm, tm)
21-
# PassManagerBuilder() do pmb
22-
# populate!(pm, pmb)
23-
# end
24-
# run!(pm, mod)
25-
#end
26-
2716
# NOTE: LLVM 12 disabled the hoisting of common instruction
2817
# before loop vectorization (https://reviews.llvm.org/D84108).
2918
#
@@ -106,6 +95,7 @@ function addOptimizationPasses!(pm, opt_level=2)
10695
loop_unswitch!(pm)
10796
licm!(pm)
10897
julia_licm!(pm)
98+
inductive_range_check_elimination!(pm)
10999
# Subsequent passes not stripping metadata from terminator
110100
instruction_simplify!(pm)
111101
ind_var_simplify!(pm)
@@ -231,6 +221,17 @@ function optimize!(@nospecialize(job::CompilerJob), mod::LLVM.Module)
231221
run!(pm, mod)
232222
end
233223

224+
# compare to Clang by using the pass manager builder APIs:
225+
#LLVM.clopts("-print-after-all", "-filter-print-funcs=$(LLVM.name(entry))")
226+
#ModulePassManager() do pm
227+
# addTargetPasses!(pm, tm, triple)
228+
# PassManagerBuilder() do pmb
229+
# optlevel!(pmb, 2)
230+
# populate!(pm, pmb)
231+
# end
232+
# run!(pm, mod)
233+
#end
234+
234235
return
235236
end
236237

src/ptx.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ function optimize_module!(@nospecialize(job::CompilerJob{PTXCompilerTarget}),
148148
add_library_info!(pm, triple(mod))
149149
add_transform_info!(pm, tm)
150150

151+
# needed by GemmKernels.jl-like code
152+
speculative_execution_if_has_branch_divergence!(pm)
153+
151154
# NVPTX's target machine info enables runtime unrolling,
152155
# but Julia's pass sequence only invokes the simple unroller.
153156
loop_unroll!(pm)

0 commit comments

Comments
 (0)