Skip to content

Commit 2887a02

Browse files
paigealeigcbot
authored andcommitted
Fix IGC constant folding bug
There was an issue in how we were Constant folding the f32tof16 GenISA intrinsic.
1 parent 574378f commit 2887a02

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

IGC/Compiler/CustomSafeOptPass.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3221,7 +3221,10 @@ Constant* IGCConstProp::ConstantFoldCallInstruction(CallInst* inst)
32213221
{
32223222
if (C0)
32233223
{
3224-
C = constantFolder.CreateFPTrunc(C0, inst->getType(), llvm::APFloatBase::rmTowardZero);
3224+
C = constantFolder.CreateFPTrunc(C0, Type::getHalfTy(inst->getContext()), llvm::APFloatBase::rmTowardZero);
3225+
C = constantFolder.CreateBitCast(C, Type::getInt16Ty(inst->getContext()));
3226+
C = constantFolder.CreateZExtOrBitCast(C, Type::getInt32Ty(inst->getContext()));
3227+
C = constantFolder.CreateBitCast(C, inst->getType());
32253228
}
32263229
}
32273230
break;

0 commit comments

Comments
 (0)