Skip to content

Commit e70be3b

Browse files
krystian-andrzejewskiigcbot
authored andcommitted
Fix combining AI and LOD Bias texture sampling coordinates
This change is to avoid incorrect constant folding results for negative values of AI (array index) coordinates. FPTOUI may produce poison values for such values.
1 parent a85c3b8 commit e70be3b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

IGC/Compiler/CISACodeGen/helper.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2720,7 +2720,10 @@ namespace IGC
27202720
Function* rdneFunc = GenISAIntrinsic::getDeclaration(
27212721
builder.GetInsertBlock()->getModule(),
27222722
GenISAIntrinsic::GenISA_ROUNDNE);
2723-
Value* intParam1 = builder.CreateFPToUI(
2723+
// FPToUI cannot be used to avoid generation of a poison value in case of
2724+
// the negative constant value. Such an approach is possible since
2725+
// there is a protection against exceeding limits by param1.
2726+
Value* intParam1 = builder.CreateFPToSI(
27242727
builder.CreateCall(rdneFunc, param1),
27252728
builder.getInt32Ty(),
27262729
VALUE_NAME(std::string("_int") + param1Name));

0 commit comments

Comments
 (0)