@@ -141,22 +141,53 @@ float _Complex a = {num, num};
141141// OGCG: store float %[[REAL]], ptr @a, align 4
142142// OGCG: store float %[[IMAG]], ptr getelementptr inbounds nuw ({ float, float }, ptr @a, i32 0, i32 1), align 4
143143
144+ float fp;
145+ int i = (int )fp;
146+
147+ // CIR-BEFORE-LPP: cir.global external @i = ctor : !s32i {
148+ // CIR-BEFORE-LPP: %0 = cir.get_global @i : !cir.ptr<!s32i>
149+ // CIR-BEFORE-LPP: %1 = cir.get_global @fp : !cir.ptr<!cir.float>
150+ // CIR-BEFORE-LPP: %2 = cir.load{{.*}} %1 : !cir.ptr<!cir.float>, !cir.float
151+ // CIR-BEFORE-LPP: %3 = cir.cast float_to_int %2 : !cir.float -> !s32i
152+ // CIR-BEFORE-LPP: cir.store{{.*}} %3, %0 : !s32i, !cir.ptr<!s32i>
153+ // CIR-BEFORE-LPP: }
154+
155+ // CIR: cir.func internal private @__cxx_global_var_init.4()
156+ // CIR: %[[I_ADDR:.*]] = cir.get_global @i : !cir.ptr<!s32i>
157+ // CIR: %[[FP_ADDR:.*]] = cir.get_global @fp : !cir.ptr<!cir.float>
158+ // CIR: %[[TMP_FP:.*]] = cir.load{{.*}} %[[FP_ADDR]] : !cir.ptr<!cir.float>, !cir.float
159+ // CIR: %[[FP_I32:.*]] = cir.cast float_to_int %[[TMP_FP]] : !cir.float -> !s32i
160+ // CIR: cir.store{{.*}} %[[FP_I32]], %[[I_ADDR]] : !s32i, !cir.ptr<!s32i>
161+
162+ // LLVM: define internal void @__cxx_global_var_init.4()
163+ // LLVM: %[[TMP_FP:.*]] = load float, ptr @fp, align 4
164+ // LLVM: %[[FP_I32:.*]] = fptosi float %[[TMP_FP]] to i32
165+ // LLVM: store i32 %[[FP_I32]], ptr @i, align 4
166+
167+ // OGCG: define internal void @__cxx_global_var_init.4() {{.*}} section ".text.startup"
168+ // OGCG: %[[TMP_FP:.*]] = load float, ptr @fp, align 4
169+ // OGCG: %[[FP_I32:.*]] = fptosi float %[[TMP_FP]] to i32
170+ // OGCG: store i32 %[[FP_I32]], ptr @i, align 4
171+
144172// Common init function for all globals with default priority
145173
146174// CIR: cir.func private @_GLOBAL__sub_I_[[FILENAME:.*]]() {
147175// CIR: cir.call @__cxx_global_var_init() : () -> ()
148176// CIR: cir.call @__cxx_global_var_init.1() : () -> ()
149177// CIR: cir.call @__cxx_global_var_init.2() : () -> ()
150178// CIR: cir.call @__cxx_global_var_init.3() : () -> ()
179+ // CIR: cir.call @__cxx_global_var_init.4() : () -> ()
151180
152181// LLVM: define void @_GLOBAL__sub_I_[[FILENAME]]()
153182// LLVM: call void @__cxx_global_var_init()
154183// LLVM: call void @__cxx_global_var_init.1()
155184// LLVM: call void @__cxx_global_var_init.2()
156185// LLVM: call void @__cxx_global_var_init.3()
186+ // LLVM: call void @__cxx_global_var_init.4()
157187
158188// OGCG: define internal void @_GLOBAL__sub_I_[[FILENAME]]() {{.*}} section ".text.startup" {
159189// OGCG: call void @__cxx_global_var_init()
160190// OGCG: call void @__cxx_global_var_init.1()
161191// OGCG: call void @__cxx_global_var_init.2()
162192// OGCG: call void @__cxx_global_var_init.3()
193+ // OGCG: call void @__cxx_global_var_init.4()
0 commit comments