Not fold gep 0, ... 0 for HLSL. (#2519)

not fold gep 0, ... 0 for HLSL.
This commit is contained in:
Xiang Li 2019-10-11 17:46:39 -07:00 коммит произвёл GitHub
Родитель 1e52699f2c
Коммит 77afe15b0d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 58 добавлений и 0 удалений

Просмотреть файл

@ -544,6 +544,7 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V,
if (unsigned newOpc = foldConstantCastPair(opc, CE, DestTy))
return ConstantExpr::getCast(newOpc, CE->getOperand(0), DestTy);
} else if (CE->getOpcode() == Instruction::GetElementPtr &&
false && // HLSL change - not fold gep 0, ... 0 for HLSL.
// Do not fold addrspacecast (gep 0, .., 0). It might make the
// addrspacecast uncanonicalized.
opc != Instruction::AddrSpaceCast) {

Просмотреть файл

@ -0,0 +1,43 @@
// RUN: %dxc -E main -T ps_6_0 %s | FileCheck %s
// Make sure memcpy on _b.a = b.a not crash.
// CHECK:define void @main()
struct A
{
float a;
float b;
};
struct B
{
A a;
};
struct C
{
float c;
B b;
B GetB()
{
B _b;
_b.a = b.a;
return _b;
}
};
C CreateC()
{
C c;
return c;
}
static const C c = CreateC();
static const B b = c.GetB();
float4 main() : SV_Target
{
return (float4)0;
}

Просмотреть файл

@ -0,0 +1,14 @@
// RUN: %dxc /T cs_6_0 /E main %s | FileCheck %s
// Make sure asfloat and store not crash.
// CHECK:define void @main
groupshared float2 s[2];
[numthreads(8, 8, 1)]
void main(uint2 DTid : SV_DispatchThreadID) {
for (int j = 0; j < 2; j++)
{
s[j] = float2(asfloat(DTid.x), asfloat((0xFFFFFFFF << DTid.y) << j));
}
}