@@ -13,6 +13,7 @@ typedef struct {
1313} A ;
1414
1515// CIR-DAG: !rec_A = !cir.record<struct "A" packed padded {!s8i, !s8i, !s8i, !u16i, !cir.array<!u8i x 3>}>
16+ // CIR-DAG: #bfi_more_bits = #cir.bitfield_info<name = "more_bits", storageType = !u16i, size = 4, offset = 3, isSigned = false>
1617// LLVM-DAG: %struct.A = type <{ i8, i8, i8, i16, [3 x i8] }>
1718// OGCG-DAG: %struct.A = type <{ i8, i8, i8, i16, [3 x i8] }>
1819
@@ -105,3 +106,31 @@ int load_field(S* s) {
105106// OGCG: [[TMP3:%.*]] = shl i64 [[TMP2]], 15
106107// OGCG: [[TMP4:%.*]] = ashr i64 [[TMP3]], 47
107108// OGCG: [[TMP5:%.*]] = trunc i64 [[TMP4]] to i32
109+
110+ unsigned int load_field_unsigned (A * s ) {
111+ return s -> more_bits ;
112+ }
113+
114+ //CIR: cir.func dso_local @load_field_unsigned
115+ //CIR: [[TMP0:%.*]] = cir.alloca !cir.ptr<!rec_A>, !cir.ptr<!cir.ptr<!rec_A>>, ["s", init] {alignment = 8 : i64}
116+ //CIR: [[TMP1:%.*]] = cir.load align(8) [[TMP0]] : !cir.ptr<!cir.ptr<!rec_A>>, !cir.ptr<!rec_A>
117+ //CIR: [[TMP2:%.*]] = cir.get_member [[TMP1]][3] {name = "more_bits"} : !cir.ptr<!rec_A> -> !cir.ptr<!u16i>
118+ //CIR: [[TMP3:%.*]] = cir.get_bitfield(#bfi_more_bits, [[TMP2]] : !cir.ptr<!u16i>) -> !u32i
119+
120+ //LLVM: define dso_local i32 @load_field_unsigned
121+ //LLVM: [[TMP0:%.*]] = alloca ptr, i64 1, align 8
122+ //LLVM: [[TMP1:%.*]] = load ptr, ptr [[TMP0]], align 8
123+ //LLVM: [[TMP2:%.*]] = getelementptr %struct.A, ptr [[TMP1]], i32 0, i32 3
124+ //LLVM: [[TMP3:%.*]] = load i16, ptr [[TMP2]], align 2
125+ //LLVM: [[TMP4:%.*]] = lshr i16 [[TMP3]], 3
126+ //LLVM: [[TMP5:%.*]] = and i16 [[TMP4]], 15
127+ //LLVM: [[TMP6:%.*]] = zext i16 [[TMP5]] to i32
128+
129+ //OGCG: define dso_local i32 @load_field_unsigned
130+ //OGCG: [[TMP0:%.*]] = alloca ptr, align 8
131+ //OGCG: [[TMP1:%.*]] = load ptr, ptr [[TMP0]], align 8
132+ //OGCG: [[TMP2:%.*]] = getelementptr inbounds nuw %struct.A, ptr [[TMP1]], i32 0, i32 3
133+ //OGCG: [[TMP3:%.*]] = load i16, ptr [[TMP2]], align 1
134+ //OGCG: [[TMP4:%.*]] = lshr i16 [[TMP3]], 3
135+ //OGCG: [[TMP5:%.*]] = and i16 [[TMP4]], 15
136+ //OGCG: [[TMP6:%.*]] = zext i16 [[TMP5]] to i32
0 commit comments