Skip to content

Commit 7e79a06

Browse files
committed
[GISel] Explicitly disable BF16 tablegen patterns.
We currently have an issue where bf16 patters can be used to match fp16 types, as GISel does not know about the difference between the two types. This patch explicitly disables them to make sure that they are never used.
1 parent 2a51a0d commit 7e79a06

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

llvm/test/CodeGen/AArch64/fptrunc.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3
22
; RUN: llc -mtriple=aarch64 -global-isel=0 -verify-machineinstrs %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-SD
33
; RUN: llc -mtriple=aarch64 -global-isel=1 -verify-machineinstrs %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-GI
4+
; RUN: llc -mtriple=aarch64 -global-isel=1 -mattr=+fullfp16,+bf16 -verify-machineinstrs %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-GI
45

56
define float @fptrunc_f64_f32(double %a) {
67
; CHECK-LABEL: fptrunc_f64_f32:

llvm/utils/TableGen/GlobalISelEmitter.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2346,6 +2346,20 @@ void GlobalISelEmitter::emitRunCustomAction(raw_ostream &OS) {
23462346
<< "}\n";
23472347
}
23482348

2349+
bool hasBFloatType(const TreePatternNode &Node) {
2350+
for (unsigned I = 0, E = Node.getNumTypes(); I < E; I++) {
2351+
auto Ty = Node.getType(I);
2352+
for (auto T : Ty)
2353+
if (T.second == MVT::bf16 ||
2354+
(T.second.isVector() && T.second.getScalarType() == MVT::bf16))
2355+
return true;
2356+
}
2357+
for (const TreePatternNode &C : Node.children())
2358+
if (hasBFloatType(C))
2359+
return true;
2360+
return false;
2361+
}
2362+
23492363
void GlobalISelEmitter::run(raw_ostream &OS) {
23502364
if (!UseCoverageFile.empty()) {
23512365
RuleCoverage = CodeGenCoverage();
@@ -2382,6 +2396,13 @@ void GlobalISelEmitter::run(raw_ostream &OS) {
23822396

23832397
if (Pat.getGISelShouldIgnore())
23842398
continue; // skip without warning
2399+
2400+
// Skip any patterns containing BF16 types, as GISel cannot currently tell
2401+
// the difference between fp16 and bf16. FIXME: This can be removed once
2402+
// BF16 is supported properly.
2403+
if (hasBFloatType(Pat.getSrcPattern()))
2404+
continue;
2405+
23852406
auto MatcherOrErr = runOnPattern(Pat);
23862407

23872408
// The pattern analysis can fail, indicating an unsupported pattern.

0 commit comments

Comments
 (0)