Skip to content

Commit 162c2b5

Browse files
committed
two test showing truncation to scalar
1 parent 89709ad commit 162c2b5

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

clang/test/CodeGenHLSL/BasicFeatures/ArrayFlatCast.hlsl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -disable-llvm-passes -emit-llvm -finclude-default-header -o - %s | FileCheck %s
22

3+
// array truncation to a scalar
4+
// CHECK-LABEL: define void {{.*}}call0
5+
// CHECK: [[A:%.*]] = alloca [2 x i32], align 4
6+
// CHECK-NEXT: [[B:%.*]] = alloca float, align 4
7+
// CHECK-NEXT: [[Tmp:%.*]] = alloca [2 x i32], align 4
8+
// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[A]], ptr align 4 {{.*}}, i32 8, i1 false)
9+
// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[Tmp]], ptr align 4 [[A]], i32 8, i1 false)
10+
// CHECK-NEXT: [[G1:%.*]] = getelementptr inbounds [2 x i32], ptr [[Tmp]], i32 0, i32 0
11+
// CHECK-NEXT: [[G2:%.*]] = getelementptr inbounds [2 x i32], ptr [[Tmp]], i32 0, i32 1
12+
// CHECK-NEXT: [[L:%.*]] = load i32, ptr [[G1]], align 4
13+
// CHECK-NEXT: store i32 [[L]], ptr [[B]], align 4
14+
export void call0() {
15+
int A[2] = {0,1};
16+
float B = (float)A;
17+
}
18+
319
// array truncation
420
// CHECK-LABEL: define void {{.*}}call1
521
// CHECK: [[A:%.*]] = alloca [2 x i32], align 4

clang/test/CodeGenHLSL/BasicFeatures/StructFlatCast.hlsl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@ struct S {
55
float Y;
66
};
77

8+
// struct truncation to a scalar
9+
// CHECK-LABEL: define void {{.*}}call0
10+
// CHECK: [[s:%.*]] = alloca %struct.S, align 4
11+
// CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
12+
// CHECK-NEXT: [[Tmp:%.*]] = alloca %struct.S, align 4
13+
// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[s]], ptr align 4 {{.*}}, i32 8, i1 false)
14+
// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[Tmp]], ptr align 4 [[s]], i32 8, i1 false)
15+
// CHECK-NEXT: [[G1:%.*]] = getelementptr inbounds %struct.S, ptr [[Tmp]], i32 0, i32 0
16+
// CHECK-NEXT: [[G2:%.*]] = getelementptr inbounds %struct.S, ptr [[Tmp]], i32 0, i32 1
17+
// CHECK-NEXT: [[L:%.*]] = load i32, ptr [[G1]], align 4
18+
// CHECK-NEXT: store i32 [[L]], ptr [[A]], align 4
19+
export void call0() {
20+
S s = {1,2};
21+
int A = (int)s;
22+
}
23+
824
// struct from vector
925
// CHECK-LABEL: define void {{.*}}call1
1026
// CHECK: [[A:%.*]] = alloca <2 x i32>, align 8

0 commit comments

Comments
 (0)