Skip to content
Closed
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
19 changes: 15 additions & 4 deletions src/llvm-demote-float16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,23 @@ static bool have_fp16(Function &caller, const Triple &TT) {
}

static bool have_bf16(Function &caller, const Triple &TT) {
if (caller.hasFnAttribute("julia.hasbf16")) {
return true;
Attribute FSAttr = caller.getFnAttribute("target-features");
StringRef FS = "";
if (FSAttr.isValid()) {
FS = FSAttr.getValueAsString();
} else if (jl_ExecutionEngine) {
FS = jl_ExecutionEngine->getTargetFeatureString();
}
if (TT.isAArch64()) {
if (FS.find("+bf16") != llvm::StringRef::npos) {
return true;
}
} else if (TT.getArch() == Triple::x86_64) {
if (caller.hasFnAttribute("julia.hasbf16")) {
return true;
}
}

// there's no targets that fully support bfloat yet;,
// AVX512BF16 only provides conversion and dot product instructions.
return false;
}

Expand Down