Skip to content

Commit 917ab09

Browse files
authored
Take care case dynamic indexing on vector start with offset. (#3558) (#3560)
* Take care case dynamic indexing on vector start with offset.
1 parent e62bc4d commit 917ab09

3 files changed

Lines changed: 50 additions & 1 deletion

File tree

lib/HLSL/HLOperationLower.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6657,7 +6657,7 @@ void TranslateCBGepLegacy(GetElementPtrInst *GEP, Value *handle,
66576657

66586658
// Load the whole register.
66596659
Value *newLd = GenerateCBLoadLegacy(handle, legacyIndex,
6660-
/*channelOffset*/ 0, EltTy,
6660+
/*channelOffset*/ channel, EltTy,
66616661
/*vecSize*/ vecSize, hlslOP, Builder);
66626662
// Copy to array.
66636663
IRBuilder<> AllocaBuilder(GEP->getParent()->getParent()->getEntryBlock().getFirstInsertionPt());
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %dxc -E main -T ps_6_0 %s | FileCheck %s
2+
3+
// Make sure store yzw to float3.
4+
// CHECK:%[[X:.*]] = extractvalue %dx.types.CBufRet.f32 %{{.*}}, 1
5+
// CHECK:%[[Y:.*]] = extractvalue %dx.types.CBufRet.f32 %{{.*}}, 2
6+
// CHECK:%[[Z:.*]] = extractvalue %dx.types.CBufRet.f32 %{{.*}}, 3
7+
// CHECK:%[[PX:.*]] = getelementptr inbounds [3 x float], [3 x float]* %{{.*}}, i32 0, i32 0
8+
// CHECK:store float %[[X]], float* %[[PX]], align 4
9+
// CHECK:%[[PY:.*]] = getelementptr inbounds [3 x float], [3 x float]* %{{.*}}, i32 0, i32 1
10+
// CHECK:store float %[[Y]], float* %[[PY]], align 4
11+
// CHECK:%[[PZ:.*]] = getelementptr inbounds [3 x float], [3 x float]* %{{.*}}, i32 0, i32 2
12+
// CHECK:store float %[[Z]], float* %[[PZ]], align 4
13+
14+
cbuffer cb
15+
{
16+
uint i;
17+
float3 v;
18+
};
19+
20+
float4 main() : SV_TARGET
21+
{
22+
return v[i];
23+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %dxc -E main -T ps_6_6 -enable-16bit-types -HV 2018 %s | FileCheck %s
2+
3+
// Make sure store .1234 to half4.
4+
// CHECK:%[[X:.*]] = extractvalue %dx.types.CBufRet.f16.8 %{{.*}}, 1
5+
// CHECK:%[[Y:.*]] = extractvalue %dx.types.CBufRet.f16.8 %{{.*}}, 2
6+
// CHECK:%[[Z:.*]] = extractvalue %dx.types.CBufRet.f16.8 %{{.*}}, 3
7+
// CHECK:%[[W:.*]] = extractvalue %dx.types.CBufRet.f16.8 %{{.*}}, 4
8+
// CHECK:%[[PX:.*]] = getelementptr inbounds [4 x half], [4 x half]* %{{.*}}, i32 0, i32 0
9+
// CHECK:store half %[[X]], half* %[[PX]], align 2
10+
// CHECK:%[[PY:.*]] = getelementptr inbounds [4 x half], [4 x half]* %{{.*}}, i32 0, i32 1
11+
// CHECK:store half %[[Y]], half* %[[PY]], align 2
12+
// CHECK:%[[PZ:.*]] = getelementptr inbounds [4 x half], [4 x half]* %{{.*}}, i32 0, i32 2
13+
// CHECK:store half %[[Z]], half* %[[PZ]], align 2
14+
// CHECK:%[[PW:.*]] = getelementptr inbounds [4 x half], [4 x half]* %{{.*}}, i32 0, i32 3
15+
// CHECK:store half %[[W]], half* %[[PW]], align 2
16+
17+
cbuffer cb
18+
{
19+
int16_t i;
20+
half4 v;
21+
};
22+
23+
float4 main() : SV_TARGET
24+
{
25+
return v[i];
26+
}

0 commit comments

Comments
 (0)