Skip to content

Commit 82e5bb0

Browse files
committed
add extra test
1 parent 6374c41 commit 82e5bb0

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

clang/test/CodeGenHLSL/BasicFeatures/StructElementwiseCast.hlsl

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,3 +310,36 @@ struct MoreBFields {
310310
export void call13(int A) {
311311
MoreBFields MBF = (MoreBFields)A;
312312
}
313+
314+
struct Inner {
315+
int Z;
316+
int Y : 25;
317+
};
318+
319+
struct Outer {
320+
int A;
321+
Inner I;
322+
};
323+
324+
// show usage of "extra" gep for struct containing bitfield
325+
// CHECK-LABEL: call14
326+
// CHECK: [[AA:%.*]] = alloca i32, align 4
327+
// CHECK-NEXT: [[O:%.*]] = alloca %struct.Outer, align 1
328+
// CHECK-NEXT: store i32 %A, ptr [[AA]], align 4
329+
// CHECK-NEXT: [[Z:%.*]] = load i32, ptr [[AA]], align 4
330+
// CHECK-NEXT: [[FieldA:%.*]] = getelementptr inbounds %struct.Outer, ptr [[O]], i32 0, i32 0
331+
// showing real usage of "extra gep". need Inner struct to generate access of its bitfield.
332+
// CHECK-NEXT: [[FieldI:%.*]] = getelementptr inbounds %struct.Outer, ptr [[O]], i32 0, i32 1
333+
// CHECK-NEXT: [[FieldY:%.*]] = getelementptr inbounds nuw %struct.Inner, ptr [[FieldI]], i32 0, i32 1
334+
// CHECK-NEXT: [[FieldZ:%.*]] = getelementptr inbounds %struct.Outer, ptr [[O]], i32 0, i32 1, i32 0
335+
// CHECK-NEXT: store i32 [[Z]], ptr [[FieldA]], align 4
336+
// CHECK-NEXT: store i32 [[Z]], ptr [[FieldZ]], align 4
337+
// CHECK-NEXT: [[BFL:%.*]] = load i32, ptr [[FieldY]], align 1
338+
// CHECK-NEXT: [[BFV:%.*]] = and i32 [[Z]], 33554431
339+
// CHECK-NEXT: [[BFC:%.*]] = and i32 [[BFL]], -33554432
340+
// CHECK-NEXT: [[BFS:%.*]] = or i32 [[BFC]], [[BFV]]
341+
// CHECK-NEXT: store i32 [[BFS]], ptr [[FieldY]], align 1
342+
// CHECK-NEXT: ret void
343+
export void call14(int A) {
344+
Outer O = (Outer)A;
345+
}

0 commit comments

Comments
 (0)