@@ -58,3 +58,28 @@ void foo2() {
5858// OGCG: %[[A_IMAG_PTR:.*]] = getelementptr inbounds nuw { double, double }, ptr %[[COMPLEX]], i32 0, i32 1
5959// OGCG: %[[A_IMAG:.*]] = load double, ptr %[[A_IMAG_PTR]], align 8
6060// OGCG: store double %[[A_REAL]], ptr %[[INIT]], align 8
61+
62+ void foo3 () {
63+ double _Complex a;
64+ double imag = __builtin_cimag (a);
65+ }
66+
67+ // CIR: %[[COMPLEX:.*]] = cir.alloca !cir.complex<!cir.double>, !cir.ptr<!cir.complex<!cir.double>>, ["a"]
68+ // CIR: %[[INIT:.*]] = cir.alloca !cir.double, !cir.ptr<!cir.double>, ["imag", init]
69+ // CIR: %[[TMP:.*]] = cir.load{{.*}} %[[COMPLEX]] : !cir.ptr<!cir.complex<!cir.double>>, !cir.complex<!cir.double>
70+ // CIR: %[[IMAG:.*]] = cir.complex.imag %[[TMP]] : !cir.complex<!cir.double> -> !cir.double
71+ // CIR: cir.store{{.*}} %[[IMAG]], %[[INIT]] : !cir.double, !cir.ptr<!cir.double>
72+
73+ // LLVM: %[[COMPLEX:.*]] = alloca { double, double }, i64 1, align 8
74+ // LLVM: %[[INIT:.*]] = alloca double, i64 1, align 8
75+ // LLVM: %[[TMP:.*]] = load { double, double }, ptr %[[COMPLEX]], align 8
76+ // LLVM: %[[IMAG:.*]] = extractvalue { double, double } %[[TMP]], 1
77+ // LLVM: store double %[[IMAG]], ptr %[[INIT]], align 8
78+
79+ // OGCG: %[[COMPLEX:.*]] = alloca { double, double }, align 8
80+ // OGCG: %[[INIT:.*]] = alloca double, align 8
81+ // OGCG: %[[A_REAL_PTR:.*]] = getelementptr inbounds nuw { double, double }, ptr %[[COMPLEX]], i32 0, i32 0
82+ // OGCG: %[[A_REAL:.*]] = load double, ptr %[[A_REAL_PTR]], align 8
83+ // OGCG: %[[A_IMAG_PTR:.*]] = getelementptr inbounds nuw { double, double }, ptr %[[COMPLEX]], i32 0, i32 1
84+ // OGCG: %[[A_IMAG:.*]] = load double, ptr %[[A_IMAG_PTR]], align 8
85+ // OGCG: store double %[[A_IMAG]], ptr %[[INIT]], align 8
0 commit comments