@@ -326,3 +326,28 @@ void complex_to_complex_cast() {
326326// OGCG: store i32 %[[REAL_INT_CAST]], ptr {{.*}}, align 4
327327// OGCG: store i32 %[[IMAG_INT_CAST]], ptr getelementptr inbounds nuw ({ i32, i32 }, ptr {{.*}}, i32 0, i32 1), align 4
328328
329+
330+ void lvalue_to_rvalue_bitcast () {
331+ void *a;
332+ int _Complex b = __builtin_bit_cast (int _Complex , a);
333+ }
334+
335+ // CIR-BEFORE: %{{.*}} = cir.cast(bitcast, %{{.*}} : !cir.ptr<!cir.ptr<!void>>), !cir.ptr<!cir.complex<!s32i>>
336+
337+ // CIR-AFTER: %{{.*}} = cir.cast(bitcast, %{{.*}} : !cir.ptr<!cir.ptr<!void>>), !cir.ptr<!cir.complex<!s32i>>
338+
339+ // LLVM: %[[PTR_ADDR:.*]] = alloca ptr, i64 1, align 8
340+ // LLVM: %[[COMPLEX_ADDR:.*]] = alloca { i32, i32 }, i64 1, align 4
341+ // LLVM: %[[PTR_TO_COMPLEX:.*]] = load { i32, i32 }, ptr %[[PTR_ADDR]], align 8
342+ // LLVM: store { i32, i32 } %[[PTR_TO_COMPLEX]], ptr %[[COMPLEX_ADDR]], align 4
343+
344+ // OGCG: %[[A_ADDR:.*]] = alloca ptr, align 8
345+ // OGCG: %[[B_ADDR:.*]] = alloca { i32, i32 }, align 4
346+ // OGCG: %[[A_REAL_PTR:.*]] = getelementptr inbounds nuw { i32, i32 }, ptr %[[A_ADDR]], i32 0, i32 0
347+ // OGCG: %[[A_REAL:.*]] = load i32, ptr %[[A_REAL_PTR]], align 8
348+ // OGCG: %[[A_IMAG_PTR:.*]] = getelementptr inbounds nuw { i32, i32 }, ptr %[[A_ADDR]], i32 0, i32 1
349+ // OGCG: %[[A_IMAG:.*]] = load i32, ptr %[[A_IMAG_PTR]], align 4
350+ // OGCG: %[[B_REAL_PTR:.*]] = getelementptr inbounds nuw { i32, i32 }, ptr %[[B_ADDR]], i32 0, i32 0
351+ // OGCG: %[[B_IMAG_PTR:.*]] = getelementptr inbounds nuw { i32, i32 }, ptr %[[B_ADDR]], i32 0, i32 1
352+ // OGCG: store i32 %[[A_REAL]], ptr %[[B_REAL_PTR]], align 4
353+ // OGCG: store i32 %[[A_IMAG]], ptr %[[B_IMAG_PTR]], align 4
0 commit comments