@@ -329,3 +329,31 @@ void t_multidim_init() {
329329// CHECK: %[[ELEM_12_PTR:.*]] = cir.get_element %[[ARRAY_ELEM1_PTR]][%[[OFFSET6]]] : (!cir.ptr<!cir.array<!s32i x 3>>, !s64i) -> !cir.ptr<!s32i>
330330// CHECK: %[[ELEM_12_VAL:.*]] = cir.const #cir.int<6> : !s32i
331331// CHECK: cir.store{{.*}} %[[ELEM_12_VAL]], %[[ELEM_12_PTR]] : !s32i, !cir.ptr<!s32i>
332+
333+ void test_new_with_complex_type () {
334+ _Complex float *a = new _Complex float {1 .0f , 2 .0f };
335+ }
336+
337+ // CHECK: cir.func{{.*}} @_Z26test_new_with_complex_typev
338+ // CHECK: %[[A_ADDR:.*]] = cir.alloca !cir.ptr<!cir.complex<!cir.float>>, !cir.ptr<!cir.ptr<!cir.complex<!cir.float>>>, ["a", init]
339+ // CHECK: %[[COMPLEX_SIZE:.*]] = cir.const #cir.int<8> : !u64i
340+ // CHECK: %[[NEW_COMPLEX:.*]] = cir.call @_Znwm(%[[COMPLEX_SIZE]]) : (!u64i) -> !cir.ptr<!void>
341+ // CHECK: %[[COMPLEX_PTR:.*]] = cir.cast bitcast %[[NEW_COMPLEX]] : !cir.ptr<!void> -> !cir.ptr<!cir.complex<!cir.float>>
342+ // CHECK: %[[COMPLEX_VAL:.*]] = cir.const #cir.complex<#cir.fp<1.000000e+00> : !cir.float, #cir.fp<2.000000e+00> : !cir.float> : !cir.complex<!cir.float>
343+ // CHECK: cir.store{{.*}} %[[COMPLEX_VAL]], %[[COMPLEX_PTR]] : !cir.complex<!cir.float>, !cir.ptr<!cir.complex<!cir.float>>
344+ // CHECK: cir.store{{.*}} %[[COMPLEX_PTR]], %[[A_ADDR]] : !cir.ptr<!cir.complex<!cir.float>>, !cir.ptr<!cir.ptr<!cir.complex<!cir.float>>>
345+
346+ // LLVM: define{{.*}} void @_Z26test_new_with_complex_typev
347+ // LLVM: %[[A_ADDR:.*]] = alloca ptr, i64 1, align 8
348+ // LLVM: %[[NEW_COMPLEX:.*]] = call ptr @_Znwm(i64 8)
349+ // LLVM: store { float, float } { float 1.000000e+00, float 2.000000e+00 }, ptr %[[NEW_COMPLEX]], align 8
350+ // LLVM: store ptr %[[NEW_COMPLEX]], ptr %[[A_ADDR]], align 8
351+
352+ // OGCG: define{{.*}} void @_Z26test_new_with_complex_typev
353+ // OGCG: %[[A_ADDR:.*]] = alloca ptr, align 8
354+ // OGCG: %[[NEW_COMPLEX:.*]] = call noalias noundef nonnull ptr @_Znwm(i64 noundef 8)
355+ // OGCG: %[[COMPLEX_REAL_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[NEW_COMPLEX]], i32 0, i32 0
356+ // OGCG: %[[COMPLEX_IMAG_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[NEW_COMPLEX]], i32 0, i32 1
357+ // OGCG: store float 1.000000e+00, ptr %[[COMPLEX_REAL_PTR]], align 8
358+ // OGCG: store float 2.000000e+00, ptr %[[COMPLEX_IMAG_PTR]], align 4
359+ // OGCG: store ptr %[[NEW_COMPLEX]], ptr %[[A_ADDR]], align 8
0 commit comments