Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/jitlayers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1897,7 +1897,17 @@ void optimizeDLSyms(Module &M) JL_NOTSAFEPOINT_LEAVE JL_NOTSAFEPOINT_ENTER {
void fixupTM(TargetMachine &TM) {
auto TheTriple = TM.getTargetTriple();
if (jl_options.opt_level < 2) {
if (!TheTriple.isARM() && !TheTriple.isPPC64() && !TheTriple.isAArch64())
// Try GlobalISel on AArch64 - it's the default in LLVM at -O0 and
// is apparently generally faster than SelectionDAG while producing good code.
// Use fallback mode so unsupported patterns fall back to SelectionDAG.
// Note: Requires RemoveJuliaAddrspacesPass to run before codegen
// because GlobalISel doesn't handle Julia's custom address spaces.
if (TheTriple.isAArch64()) {
TM.setGlobalISel(true);
TM.setGlobalISelAbort(GlobalISelAbortMode::Disable);
TM.setFastISel(false);
}
else if (!TheTriple.isARM() && !TheTriple.isPPC64())
TM.setFastISel(true);
else // FastISel seems to be buggy Ref #13321
TM.setFastISel(false);
Expand Down
12 changes: 12 additions & 0 deletions test/atomics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1115,3 +1115,15 @@ function add_one57190!()
end

@test add_one57190!() == 1

# Test atomic Float16 operations at all optimization levels (GlobalISel miscompile on AArch64)
# See https://github.com/JuliaLang/julia/pull/54140#issuecomment-2855794363
for opt in 0:3
@test success(run(```$(Base.julia_cmd()) --startup-file=no -O$opt -e '
a = Threads.Atomic{Float16}(Float16(0))
a[] = Float16(1.5)
@assert a[] === Float16(1.5) "atomic Float16 store failed: got \$(a[]) expected 1.5 (opt level = -O$(Base.JLOptions().opt_level))"
a[] = Float16(3.25)
@assert a[] === Float16(3.25) "atomic Float16 store failed: got \$(a[]) expected 3.25 (opt level = -O$(Base.JLOptions().opt_level))"
'```))
end