File tree Expand file tree Collapse file tree 4 files changed +42
-1
lines changed Expand file tree Collapse file tree 4 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -921,7 +921,7 @@ void GenXBaling::processSat(Instruction *Inst) {
921
921
setOperandBaled (Inst, OperandNum, &BI);
922
922
} else if (ValIntrinID == GenXIntrinsic::not_any_intrinsic) {
923
923
if (isa<BinaryOperator>(V) || isa<SelectInst>(V) ||
924
- (isa<CastInst>(V) && !isa<BitCastInst>(V))) {
924
+ (isa<CastInst>(V) && !isa<BitCastInst>(V) && ! isBFloat16Cast (V) )) {
925
925
LLVM_DEBUG (llvm::dbgs ()
926
926
<< __FUNCTION__ << " setting operand #" << OperandNum
927
927
<< " to bale in instruction " << *Inst << " \n " );
Original file line number Diff line number Diff line change @@ -407,6 +407,22 @@ bool genx::isNoopCast(const CastInst *CI) {
407
407
}
408
408
}
409
409
410
+ bool genx::isBFloat16Cast (const Instruction *I) {
411
+ #if LLVM_VERSION_MAJOR >= 11
412
+ Type *Ty = nullptr ;
413
+ if (isa<FPTruncInst>(I))
414
+ Ty = I->getType ();
415
+ else if (isa<FPExtInst>(I))
416
+ Ty = I->getOperand (0 )->getType ();
417
+ else
418
+ return false ;
419
+ IGC_ASSERT_EXIT (Ty);
420
+ return Ty->getScalarType ()->isBFloatTy ();
421
+ #else // LLVM_VERSION_MAJOR >= 11
422
+ return false ;
423
+ #endif // LLVM_VERSION_MAJOR >= 11
424
+ }
425
+
410
426
/* **********************************************************************
411
427
* ShuffleVectorAnalyzer::getAsSlice : see if the shufflevector is a slice on
412
428
* operand 0, and if so return the start index, or -1 if it is not a slice
Original file line number Diff line number Diff line change @@ -252,6 +252,9 @@ bool isFuncPointerVec(Value *V);
252
252
// of value (in other words, it can be copy-coalesced).
253
253
bool isNoopCast (const CastInst *CI);
254
254
255
+ // isBFloat16Cast : test if cast operation extends bfloat or truncates to bfloat
256
+ bool isBFloat16Cast (const Instruction *I);
257
+
255
258
// ShuffleVectorAnalyzer : class to analyze a shufflevector
256
259
class ShuffleVectorAnalyzer {
257
260
ShuffleVectorInst *SI;
Original file line number Diff line number Diff line change
1
+ ;=========================== begin_copyright_notice ============================
2
+ ;
3
+ ; Copyright (C) 2023 Intel Corporation
4
+ ;
5
+ ; SPDX-License-Identifier: MIT
6
+ ;
7
+ ;============================ end_copyright_notice =============================
8
+
9
+ ; REQUIRES: llvm_12_or_greater
10
+ ; RUN: %opt %use_old_pass_manager% -GenXFuncBaling -print-baling-info -disable-output -march=genx64 -mcpu=XeHPG -mtriple=spir64-unknown-unknown -S < %s | FileCheck %s
11
+
12
+ declare <16 x float > @llvm.genx.sat.v16f32 (<16 x float >)
13
+
14
+ define <16 x float > @test_ext (<16 x bfloat> %src ) {
15
+ ; CHECK: bales in function: test_ext:
16
+ ; CHECK-NEXT: %sat = call <16 x float> @llvm.genx.sat.v16f32(<16 x float> %ext):
17
+ ; CHECK-SAME: {{ saturate$}}
18
+ ; CHECK-NEXT: GenXBaling dump end
19
+ %ext = fpext <16 x bfloat> %src to <16 x float >
20
+ %sat = call <16 x float > @llvm.genx.sat.v16f32 (<16 x float > %ext )
21
+ ret <16 x float > %sat
22
+ }
You can’t perform that action at this time.
0 commit comments