@@ -398,3 +398,23 @@ int extract_imag_and_add(int _Complex a, int _Complex b) {
398398void complex_with_empty_init () { int _Complex c = {}; }
399399
400400// CHECK: {{.*}} = cir.const #cir.complex<#cir.int<0> : !s32i, #cir.int<0> : !s32i> : !cir.complex<!s32i>
401+
402+ void complex_array_subscript () {
403+ int _Complex arr [2 ];
404+ int _Complex r = arr [1 ];
405+ }
406+
407+ // CHECK: %[[ARR:.*]] = cir.alloca !cir.array<!cir.complex<!s32i> x 2>, !cir.ptr<!cir.array<!cir.complex<!s32i> x 2>>, ["arr"]
408+ // CHECK: %[[RESULT:.*]] = cir.alloca !cir.complex<!s32i>, !cir.ptr<!cir.complex<!s32i>>, ["r", init]
409+ // CHECK: %[[IDX:.*]] = cir.const #cir.int<1> : !s32i
410+ // CHECK: %[[ARR_PTR:.*]] = cir.cast(array_to_ptrdecay, %[[ARR]] : !cir.ptr<!cir.array<!cir.complex<!s32i> x 2>>), !cir.ptr<!cir.complex<!s32i>>
411+ // CHECK: %[[RESULT_VAL:.*]] = cir.ptr_stride(%[[ARR_PTR]] : !cir.ptr<!cir.complex<!s32i>>, %[[IDX]] : !s32i), !cir.ptr<!cir.complex<!s32i>>
412+ // CHECK: %[[TMP:.*]] = cir.load{{.*}} %[[RESULT_VAL]] : !cir.ptr<!cir.complex<!s32i>>, !cir.complex<!s32i>
413+ // CHECK: cir.store{{.*}} %[[TMP]], %[[RESULT]] : !cir.complex<!s32i>, !cir.ptr<!cir.complex<!s32i>>
414+
415+ // LLVM: %[[ARR:.*]] = alloca [2 x { i32, i32 }], i64 1, align 16
416+ // LLVM: %[[RESULT:.*]] = alloca { i32, i32 }, i64 1, align 4
417+ // LLVM: %[[ARR_PTR:.*]] = getelementptr { i32, i32 }, ptr %[[ARR]], i32 0
418+ // LLVM: %[[RESULT_VAL:.*]] = getelementptr { i32, i32 }, ptr %[[ARR_PTR]], i64 1
419+ // LLVM: %[[TMP:.*]] = load { i32, i32 }, ptr %[[RESULT_VAL]], align 8
420+ // LLVM: store { i32, i32 } %[[TMP]], ptr %[[RESULT]], align 4
0 commit comments