@@ -83,3 +83,45 @@ void store_field() {
8383// OGCG: [[TMP2:%.*]] = and i64 [[TMP1]], -16
8484// OGCG: [[TMP3:%.*]] = or i64 [[TMP2]], 3
8585// OGCG: store i64 [[TMP3]], ptr [[TMP0]], align 4
86+
87+ void store_bitfield_to_bitfield (S* s) {
88+ s->a = s->b = 3 ;
89+ }
90+
91+ // CIR: cir.func dso_local @_Z26store_bitfield_to_bitfieldP1S
92+ // CIR: [[TMP0:%.*]] = cir.alloca !cir.ptr<!rec_S>, !cir.ptr<!cir.ptr<!rec_S>>, ["s", init] {alignment = 8 : i64}
93+ // CIR: [[TMP1:%.*]] = cir.const #cir.int<3> : !s32i
94+ // CIR: [[TMP2:%.*]] = cir.load align(8) [[TMP0]] : !cir.ptr<!cir.ptr<!rec_S>>, !cir.ptr<!rec_S>
95+ // CIR: [[TMP3:%.*]] = cir.get_member [[TMP2]][0] {name = "b"} : !cir.ptr<!rec_S> -> !cir.ptr<!u64i>
96+ // CIR: [[TMP4:%.*]] = cir.set_bitfield(#bfi_b, [[TMP3]] : !cir.ptr<!u64i>, [[TMP1]] : !s32i) -> !s32i
97+ // CIR: [[TMP5:%.*]] = cir.load align(8) [[TMP0]] : !cir.ptr<!cir.ptr<!rec_S>>, !cir.ptr<!rec_S>
98+ // CIR: [[TMP6:%.*]] = cir.get_member [[TMP5]][0] {name = "a"} : !cir.ptr<!rec_S> -> !cir.ptr<!u64i>
99+ // CIR: [[TMP7:%.*]] = cir.set_bitfield(#bfi_a, [[TMP6]] : !cir.ptr<!u64i>, [[TMP4]] : !s32i) -> !s32i
100+
101+ // LLVM: define dso_local void @_Z26store_bitfield_to_bitfieldP1S
102+ // LLVM: [[TMP0:%.*]] = alloca ptr, i64 1, align 8
103+ // LLVM: [[TMP1:%.*]] = load ptr, ptr [[TMP0]], align 8
104+ // LLVM: [[TMP2:%.*]] = getelementptr %struct.S, ptr [[TMP1]], i32 0, i32 0
105+ // LLVM: [[TMP3:%.*]] = load i64, ptr [[TMP2]], align 8
106+ // LLVM: [[TMP4:%.*]] = and i64 [[TMP3]], -2147483633
107+ // LLVM: [[TMP5:%.*]] = or i64 [[TMP4]], 48
108+ // LLVM: store i64 [[TMP5]], ptr [[TMP2]], align 8
109+ // LLVM: [[TMP6:%.*]] = load ptr, ptr [[TMP0]], align 8
110+ // LLVM: [[TMP7:%.*]] = getelementptr %struct.S, ptr [[TMP6]], i32 0, i32 0
111+ // LLVM: [[TMP8:%.*]] = load i64, ptr [[TMP7]], align 8
112+ // LLVM: [[TMP9:%.*]] = and i64 [[TMP8]], -16
113+ // LLVM: [[TMP10:%.*]] = or i64 [[TMP9]], 3
114+ // LLVM: store i64 [[TMP10]], ptr [[TMP7]], align 8
115+
116+ // OGCG: define dso_local void @_Z26store_bitfield_to_bitfieldP1S
117+ // OGCG: [[TMP0:%.*]] = alloca ptr, align 8
118+ // OGCG: [[TMP1:%.*]] = load ptr, ptr [[TMP0]], align 8
119+ // OGCG: [[TMP2:%.*]] = load i64, ptr [[TMP1]], align 4
120+ // OGCG: [[TMP3:%.*]] = and i64 [[TMP2]], -2147483633
121+ // OGCG: [[TMP4:%.*]] = or i64 [[TMP3]], 48
122+ // OGCG: store i64 [[TMP4]], ptr [[TMP1]], align 4
123+ // OGCG: [[TMP5:%.*]] = load ptr, ptr [[TMP0]], align 8
124+ // OGCG: [[TMP6:%.*]] = load i64, ptr [[TMP5]], align 4
125+ // OGCG: [[TMP7:%.*]] = and i64 [[TMP6]], -16
126+ // OGCG: [[TMP8:%.*]] = or i64 [[TMP7]], 3
127+ // OGCG: store i64 [[TMP8]], ptr [[TMP5]], align 4
0 commit comments