Skip to content

Commit 230e4a8

Browse files
committed
Demote(B)Float16 pass: only keep enabled for PPC.
1 parent b7aa5e3 commit 230e4a8

File tree

1 file changed

+8
-27
lines changed

1 file changed

+8
-27
lines changed

src/llvm-demote-float16.cpp

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -50,36 +50,17 @@ extern JuliaOJIT *jl_ExecutionEngine;
5050
namespace {
5151

5252
static bool have_fp16(Function &caller, const Triple &TT) {
53-
Attribute FSAttr = caller.getFnAttribute("target-features");
54-
StringRef FS = "";
55-
if (FSAttr.isValid())
56-
FS = FSAttr.getValueAsString();
57-
else if (jl_ExecutionEngine)
58-
FS = jl_ExecutionEngine->getTargetFeatureString();
59-
// else probably called from opt, just do nothing
60-
if (TT.isAArch64()) {
61-
if (FS.find("+fp16fml") != llvm::StringRef::npos || FS.find("+fullfp16") != llvm::StringRef::npos){
62-
return true;
63-
}
64-
} else if (TT.getArch() == Triple::x86_64) {
65-
if (FS.find("+avx512fp16") != llvm::StringRef::npos){
66-
return true;
67-
}
68-
}
69-
if (caller.hasFnAttribute("julia.hasfp16")) {
70-
return true;
71-
}
72-
return false;
53+
// llvm/llvm-project#97975: on some platforms, `half` uses excessive precision
54+
if (TT.isPPC())
55+
return false;
56+
57+
return true;
7358
}
7459

7560
static bool have_bf16(Function &caller, const Triple &TT) {
76-
if (caller.hasFnAttribute("julia.hasbf16")) {
77-
return true;
78-
}
79-
80-
// there's no targets that fully support bfloat yet;,
81-
// AVX512BF16 only provides conversion and dot product instructions.
82-
return false;
61+
// https://github.com/llvm/llvm-project/issues/97975#issuecomment-2218770199:
62+
// on current versions of LLVM, bf16 always uses TypeSoftPromoteHalf
63+
return true;
8364
}
8465

8566
static bool demoteFloat16(Function &F)

0 commit comments

Comments
 (0)