@@ -169,3 +169,66 @@ int f6(void) {
169169// OGCG-NEXT: entry:
170170// OGCG-NEXT: %[[GV:.*]] = load i32, ptr @gv, align 4
171171// OGCG-NEXT: ret i32 %[[GV]]
172+
173+ int f7 (int a , int b , int c ) {
174+ return a + (b + c );
175+ }
176+
177+ // CIR: cir.func @f7
178+ // CIR: %[[A_PTR:.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["a", init]
179+ // CIR: %[[B_PTR:.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["b", init]
180+ // CIR: %[[C_PTR:.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["c", init]
181+ // CIR: %[[A:.*]] = cir.load %[[A_PTR]] : !cir.ptr<!s32i>, !s32i
182+ // CIR: %[[B:.*]] = cir.load %[[B_PTR]] : !cir.ptr<!s32i>, !s32i
183+ // CIR: %[[C:.*]] = cir.load %[[C_PTR]] : !cir.ptr<!s32i>, !s32i
184+ // CIR: %[[B_PLUS_C:.*]] = cir.binop(add, %[[B]], %[[C]]) nsw : !s32i
185+ // CIR: %[[RETVAL:.*]] = cir.binop(add, %[[A]], %[[B_PLUS_C]]) nsw : !s32i
186+
187+ // LLVM: define i32 @f7
188+ // LLVM: %[[A_PTR:.*]] = alloca i32, i64 1, align 4
189+ // LLVM: %[[B_PTR:.*]] = alloca i32, i64 1, align 4
190+ // LLVM: %[[C_PTR:.*]] = alloca i32, i64 1, align 4
191+ // LLVM: %[[A:.*]] = load i32, ptr %[[A_PTR]], align 4
192+ // LLVM: %[[B:.*]] = load i32, ptr %[[B_PTR]], align 4
193+ // LLVM: %[[C:.*]] = load i32, ptr %[[C_PTR]], align 4
194+ // LLVM: %[[B_PLUS_C:.*]] = add nsw i32 %[[B]], %[[C]]
195+ // LLVM: %[[RETVAL:.*]] = add nsw i32 %[[A]], %[[B_PLUS_C]]
196+
197+ // OGCG: define{{.*}} i32 @f7
198+ // OGCG: entry:
199+ // OGCG: %[[A_PTR:.*]] = alloca i32, align 4
200+ // OGCG: %[[B_PTR:.*]] = alloca i32, align 4
201+ // OGCG: %[[C_PTR:.*]] = alloca i32, align 4
202+ // OGCG: %[[A:.*]] = load i32, ptr %[[A_PTR]], align 4
203+ // OGCG: %[[B:.*]] = load i32, ptr %[[B_PTR]], align 4
204+ // OGCG: %[[C:.*]] = load i32, ptr %[[C_PTR]], align 4
205+ // OGCG: %[[B_PLUS_C:.*]] = add nsw i32 %[[B]], %[[C]]
206+ // OGCG: %[[RETVAL:.*]] = add nsw i32 %[[A]], %[[B_PLUS_C]]
207+
208+ int f8 (int * p ) {
209+ (* p ) = 2 ;
210+ return (* p );
211+ }
212+
213+ // CIR: cir.func @f8
214+ // CIR: %[[P_PTR:.*]] = cir.alloca !cir.ptr<!s32i>, !cir.ptr<!cir.ptr<!s32i>>, ["p", init]
215+ // CIR: %[[TWO:.*]] = cir.const #cir.int<2> : !s32i
216+ // CIR: %[[P:.*]] = cir.load deref %[[P_PTR]] : !cir.ptr<!cir.ptr<!s32i>>, !cir.ptr<!s32i>
217+ // CIR: cir.store %[[TWO]], %[[P]] : !s32i, !cir.ptr<!s32i>
218+ // CIR: %[[P2:.*]] = cir.load deref %[[P_PTR]] : !cir.ptr<!cir.ptr<!s32i>>, !cir.ptr<!s32i>
219+ // CIR: %[[STAR_P:.*]] = cir.load %[[P2]] : !cir.ptr<!s32i>, !s32i
220+
221+ // LLVM: define i32 @f8
222+ // LLVM: %[[P_PTR:.*]] = alloca ptr, i64 1, align 8
223+ // LLVM: %[[P:.*]] = load ptr, ptr %[[P_PTR]], align 8
224+ // LLVM: store i32 2, ptr %[[P]], align 4
225+ // LLVM: %[[P2:.*]] = load ptr, ptr %[[P_PTR]], align 8
226+ // LLVM: %[[STAR_P:.*]] = load i32, ptr %[[P2]], align 4
227+
228+ // OGCG: define{{.*}} i32 @f8
229+ // OGCG: entry:
230+ // OGCG: %[[P_PTR:.*]] = alloca ptr, align 8
231+ // OGCG: %[[P:.*]] = load ptr, ptr %[[P_PTR]], align 8
232+ // OGCG: store i32 2, ptr %[[P]], align 4
233+ // OGCG: %[[P2:.*]] = load ptr, ptr %[[P_PTR]], align 8
234+ // OGCG: %[[STAR_P:.*]] = load i32, ptr %[[P2]], align 4
0 commit comments