Skip to content

Commit 54b46a1

Browse files
mmereckigfxbot
authored andcommitted
Code for 64bit emulation of uint64 to float conversion uses
splitBasicBlock() which invalidates current insert point. The fix is to set the correct insert point after the method call completes. Change-Id: Id4a85268b8393a78d99d2467c622da123254421e
1 parent cec272d commit 54b46a1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

IGC/Compiler/CISACodeGen/Emu64OpsPass.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,6 +1381,13 @@ bool InstExpander::visitFPToSI(FPToSIInst &F2S) {
13811381
return true;
13821382
}
13831383

1384+
// Note: This method uses splitBasciBlock() which moves Pos (and all
1385+
// instructions following it till the end of basic block) to a new basic block.
1386+
// If IRB's insert point is set to Pos or an instruction after Pos in the same
1387+
// basic block than the insert basic block value in IRB will be invalid after
1388+
// this method completes. A correct insert point should be set in IRB after this
1389+
// method is called.
1390+
//
13841391
Value *InstExpander::convertUIToFP32(Type *DstTy, Value *Lo, Value *Hi, Instruction *Pos) {
13851392
BuilderType::InsertPointGuard Guard(*IRB);
13861393
IRB->SetInsertPoint(Pos);
@@ -1499,6 +1506,7 @@ bool InstExpander::visitUIToFP(UIToFPInst &U2F) {
14991506
NewVal = IRB->CreateCall3(Fma, HiF, FC0, LoF);
15001507
} else {
15011508
NewVal = convertUIToFP32(IRB->getFloatTy(), Lo, Hi, &U2F);
1509+
IRB->SetInsertPoint(&U2F);
15021510
// It's OK to apply the same approach in `convertUIToFP32` to convert 64-bit
15031511
// integer into half. But, it would introduce a little more instructions to
15041512
// properly round the remaining 48 bits into the high 16 bits. Instead, that
@@ -1558,6 +1566,7 @@ bool InstExpander::visitSIToFP(SIToFPInst &S2F) {
15581566
Hi = IRB->CreateExtractValue(V, 1);
15591567

15601568
NewVal = convertUIToFP32(IRB->getFloatTy(), Lo, Hi, &S2F);
1569+
IRB->SetInsertPoint(&S2F);
15611570
NewVal = IRB->CreateBitCast(NewVal, IRB->getInt32Ty());
15621571
Sign = IRB->CreateAnd(Sign, IRB->getInt32(0x80000000));
15631572
NewVal = IRB->CreateOr(NewVal, Sign);

0 commit comments

Comments
 (0)