Skip to content

Commit 543ca14

Browse files
committed
[AIE2P] Fix bf16 and f32 crash
Less than Vectors of f32 = 16, 32 gets converted to 64xf32 as those are legal. Vectors of bf16 = 32xbf16 is a custom case converts other sizes into this corresponding vector.
1 parent b966462 commit 543ca14

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

llvm/lib/Target/AIE/aie2p/AIE2PLegalizerInfo.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,23 +273,25 @@ AIE2PLegalizerInfo::AIE2PLegalizerInfo(const AIE2PSubtarget &ST)
273273

274274
getActionDefinitionsBuilder({G_FADD, G_FSUB})
275275
.legalFor({AccV64S32})
276-
// .moreElementsToNextPow2(0) // non-power of 2
276+
// Handle custom bf16 case for both scalar and vector types
277+
.customFor({S16, V32S16})
278+
// Convert smaller than <32 x f32/bf16> to legal sizes, doesn't change types
277279
.moreElementsIf(
278280
[=](const LegalityQuery &Query) {
279281
const LLT &Ty = Query.Types[0];
280282
return Ty.isVector() &&
281283
(Ty.getScalarSizeInBits() == 32 ||
282284
Ty.getScalarSizeInBits() == 16) &&
283-
Ty.getNumElements() < 32;
285+
Ty.getNumElements() <= 32;
284286
},
285287
[=](const LegalityQuery &Query) {
286288
if (Query.Types[0].getScalarSizeInBits() == 32) {
287-
return std::make_pair(0, LLT::fixed_vector(32, S32));
289+
return std::make_pair(0, LLT::fixed_vector(64, S32));
288290
} else {
289291
return std::make_pair(0, LLT::fixed_vector(32, S16));
290292
}
291293
})
292-
// converts <64xbf16> into 2 chunks of <32xbf16>
294+
// Converts <64xbf16> into 2 chunks of <32xbf16>
293295
.fewerElementsIf(
294296
[=](const LegalityQuery &Query) {
295297
const LLT &Ty = Query.Types[0];
@@ -299,8 +301,6 @@ AIE2PLegalizerInfo::AIE2PLegalizerInfo(const AIE2PSubtarget &ST)
299301
[=](const LegalityQuery &Query) {
300302
return std::make_pair(0, LLT::fixed_vector(32, S16));
301303
})
302-
// Handle custom bf16 case for both scalar and vector types
303-
.customFor({S16, V32S16})
304304
.libcallFor({S32, S64});
305305

306306
getActionDefinitionsBuilder({G_FDIV, G_FREM})

0 commit comments

Comments
 (0)