@@ -434,3 +434,34 @@ void func9(int arr[10][5]) {
434434// OGCG: %[[ARR_1_2:.*]] = getelementptr inbounds [5 x i32], ptr %[[ARR_1]], i64 0, i64 2
435435// OGCG: %[[TMP_2:.*]] = load i32, ptr %[[ARR_1_2]], align 4
436436// OGCG: store i32 %[[TMP_2]], ptr %[[INIT]], align 4
437+
438+ void func10 (int *a) {
439+ int e = a[5 ];
440+ }
441+
442+ // CIR: cir.func @func10(%[[ARG:.*]]: !cir.ptr<!s32i>
443+ // CIR: %[[ARR:.*]] = cir.alloca !cir.ptr<!s32i>, !cir.ptr<!cir.ptr<!s32i>>, ["a", init]
444+ // CIR: %[[INIT:.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["e", init]
445+ // CIR: cir.store %[[ARG]], %[[ARR]] : !cir.ptr<!s32i>, !cir.ptr<!cir.ptr<!s32i>>
446+ // CIR: %[[IDX:.*]] = cir.const #cir.int<5> : !s32i
447+ // CIR: %[[TMP_1:.*]] = cir.load %[[ARR]] : !cir.ptr<!cir.ptr<!s32i>>, !cir.ptr<!s32i>
448+ // CIR: %[[ELE:.*]] = cir.ptr_stride(%[[TMP_1]] : !cir.ptr<!s32i>, %[[IDX]] : !s32i), !cir.ptr<!s32i>
449+ // CIR: %[[TMP_2:.*]] = cir.load %[[ELE]] : !cir.ptr<!s32i>, !s32i
450+ // CIR: cir.store %[[TMP_2]], %[[INIT]] : !s32i, !cir.ptr<!s32i>
451+
452+ // LLVM: define void @func10(ptr %[[ARG:.*]]) {
453+ // LLVM: %[[ARR:.*]] = alloca ptr, i64 1, align 8
454+ // LLVM: %[[INIT:.*]] = alloca i32, i64 1, align 4
455+ // LLVM: store ptr %[[ARG]], ptr %[[ARR]], align 8
456+ // LLVM: %[[TMP_1:.*]] = load ptr, ptr %[[ARR]], align 8
457+ // LLVM: %[[ELE:.*]] = getelementptr i32, ptr %[[TMP_1]], i64 5
458+ // LLVM: %[[TMP_2:.*]] = load i32, ptr %[[ELE]], align 4
459+ // LLVM: store i32 %[[TMP_2]], ptr %[[INIT]], align 4
460+
461+ // OGCG: %[[ARR:.*]] = alloca ptr, align 8
462+ // OGCG: %[[INIT:.*]] = alloca i32, align 4
463+ // OGCG: store ptr {{%.*}}, ptr %[[ARR]], align 8
464+ // OGCG: %[[TMP_1:.*]] = load ptr, ptr %[[ARR]], align 8
465+ // OGCG: %[[ELE:.*]] = getelementptr inbounds i32, ptr %[[TMP_1]], i64 5
466+ // OGCG: %[[TMP_2:.*]] = load i32, ptr %[[ELE]], align 4
467+ // OGCG: store i32 %[[TMP_2]], ptr %[[INIT]], align 4
0 commit comments