Don't change bitcast (gep a, 0, 0) into bicast a for validation. (#164)
This commit is contained in:
Родитель
7aa3fbd04b
Коммит
9afb4cfcb8
|
@ -1447,6 +1447,11 @@ Instruction *InstCombiner::commonPointerCastTransforms(CastInst &CI) {
|
|||
// If casting the result of a getelementptr instruction with no offset, turn
|
||||
// this into a cast of the original pointer!
|
||||
if (GEP->hasAllZeroIndices() &&
|
||||
// HLSL Change Begin.
|
||||
// Ignore this optimization for pointer bitcast to pass validation.
|
||||
// TODO: enable this optimization when validation is updated.
|
||||
0 &&
|
||||
// HLSL Change End.
|
||||
// If CI is an addrspacecast and GEP changes the poiner type, merging
|
||||
// GEP into CI would undo canonicalizing addrspacecast with different
|
||||
// pointer types, causing infinite loops.
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
// RUN: %dxc -E main -T ps_6_0 %s | FileCheck %s
|
||||
|
||||
// CHECK: bitcast
|
||||
|
||||
uint uintConstant;
|
||||
uint i;
|
||||
float4 main() : SV_Target
|
||||
{
|
||||
float a[2];
|
||||
|
||||
a[0] = asfloat(uintConstant);
|
||||
a[1] = 0;
|
||||
|
||||
return a[i];
|
||||
}
|
|
@ -362,6 +362,7 @@ public:
|
|||
TEST_METHOD(CodeGenGatherCmp)
|
||||
TEST_METHOD(CodeGenGatherCubeOffset)
|
||||
TEST_METHOD(CodeGenGatherOffset)
|
||||
TEST_METHOD(CodeGenGepZeroIdx)
|
||||
TEST_METHOD(CodeGenGloballyCoherent)
|
||||
TEST_METHOD(CodeGenIcb1)
|
||||
TEST_METHOD(CodeGenIf1)
|
||||
|
@ -2229,6 +2230,10 @@ TEST_F(CompilerTest, CodeGenGatherOffset) {
|
|||
CodeGenTestCheck(L"..\\CodeGenHLSL\\gatherOffset.hlsl");
|
||||
}
|
||||
|
||||
TEST_F(CompilerTest, CodeGenGepZeroIdx) {
|
||||
CodeGenTestCheck(L"..\\CodeGenHLSL\\gep_zero_idx.hlsl");
|
||||
}
|
||||
|
||||
TEST_F(CompilerTest, CodeGenGloballyCoherent) {
|
||||
CodeGenTestCheck(L"..\\CodeGenHLSL\\globallycoherent.hlsl");
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче