Skip to content

Commit 9f0c449

Browse files
authored
[CIR][NFC] Add test for Complex imag with GUN extension (#167215)
Add a test for Complex imag with GUN extension from the incubator
1 parent 4cd16f2 commit 9f0c449

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

clang/test/CIR/CodeGen/complex.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,3 +1495,42 @@ void calling_function_that_return_complex() {
14951495
// OGCG: %[[A_IMAG_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[A_ADDR]], i32 0, i32 1
14961496
// OGCG: store float %[[RESULT_REAL]], ptr %[[A_REAL_PTR]], align 4
14971497
// OGCG: store float %[[RESULT_IMAG]], ptr %[[A_IMAG_PTR]], align 4
1498+
1499+
void imag_literal_with_gun_extension() {
1500+
float _Complex a = 3.0fi;
1501+
double _Complex b = 3.0i;
1502+
int _Complex c = 3i;
1503+
}
1504+
1505+
// CIR: %[[A_ADDR:.*]] = cir.alloca !cir.complex<!cir.float>, !cir.ptr<!cir.complex<!cir.float>>, ["a", init]
1506+
// CIR: %[[B_ADDR:.*]] = cir.alloca !cir.complex<!cir.double>, !cir.ptr<!cir.complex<!cir.double>>, ["b", init]
1507+
// CIR: %[[C_ADDR:.*]] = cir.alloca !cir.complex<!s32i>, !cir.ptr<!cir.complex<!s32i>>, ["c", init]
1508+
// CIR: %[[COMPLEX_A:.*]] = cir.const #cir.const_complex<#cir.fp<0.000000e+00> : !cir.float, #cir.fp<3.000000e+00> : !cir.float> : !cir.complex<!cir.float>
1509+
// CIR: cir.store{{.*}} %[[COMPLEX_A]], %[[A_ADDR]] : !cir.complex<!cir.float>, !cir.ptr<!cir.complex<!cir.float>>
1510+
// CIR: %[[COMPLEX_B:.*]] = cir.const #cir.const_complex<#cir.fp<0.000000e+00> : !cir.double, #cir.fp<3.000000e+00> : !cir.double> : !cir.complex<!cir.double>
1511+
// CIR: cir.store{{.*}} %[[COMPLEX_B]], %[[B_ADDR]] : !cir.complex<!cir.double>, !cir.ptr<!cir.complex<!cir.double>>
1512+
// CIR: %[[COMPLEX_C:.*]] = cir.const #cir.const_complex<#cir.int<0> : !s32i, #cir.int<3> : !s32i> : !cir.complex<!s32i>
1513+
// CIR: cir.store{{.*}} %[[COMPLEX_C]], %[[C_ADDR]] : !cir.complex<!s32i>, !cir.ptr<!cir.complex<!s32i>>
1514+
1515+
// LLVM: %[[A_ADDR:.*]] = alloca { float, float }, i64 1, align 4
1516+
// LLVM: %[[B_ADDR:.*]] = alloca { double, double }, i64 1, align 8
1517+
// LLVM: %[[C_ADDR:.*]] = alloca { i32, i32 }, i64 1, align 4
1518+
// LLVM: store { float, float } { float 0.000000e+00, float 3.000000e+00 }, ptr %[[A_ADDR]], align 4
1519+
// LLVM: store { double, double } { double 0.000000e+00, double 3.000000e+00 }, ptr %[[B_ADDR]], align 8
1520+
// LLVM: store { i32, i32 } { i32 0, i32 3 }, ptr %[[C_ADDR]], align 4
1521+
1522+
// OGCG: %[[A_ADDR:.*]] = alloca { float, float }, align 4
1523+
// OGCG: %[[B_ADDR:.*]] = alloca { double, double }, align 8
1524+
// OGCG: %[[C_ADDR:.*]] = alloca { i32, i32 }, align 4
1525+
// OGCG: %[[A_REAL_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[A_ADDR]], i32 0, i32 0
1526+
// OGCG: %[[A_IMAG_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[A_ADDR]], i32 0, i32 1
1527+
// OGCG: store float 0.000000e+00, ptr %[[A_REAL_PTR]], align 4
1528+
// OGCG: store float 3.000000e+00, ptr %[[A_IMAG_PTR]], align 4
1529+
// OGCG: %[[B_REAL_PTR:.*]] = getelementptr inbounds nuw { double, double }, ptr %[[B_ADDR]], i32 0, i32 0
1530+
// OGCG: %[[B_IMAG_PTR:.*]] = getelementptr inbounds nuw { double, double }, ptr %[[B_ADDR]], i32 0, i32 1
1531+
// OGCG: store double 0.000000e+00, ptr %[[B_REAL_PTR]], align 8
1532+
// OGCG: store double 3.000000e+00, ptr %[[B_IMAG_PTR]], align 8
1533+
// OGCG: %[[C_REAL_PTR:.*]] = getelementptr inbounds nuw { i32, i32 }, ptr %[[C_ADDR]], i32 0, i32 0
1534+
// OGCG: %[[C_IMAG_PTR:.*]] = getelementptr inbounds nuw { i32, i32 }, ptr %[[C_ADDR]], i32 0, i32 1
1535+
// OGCG: store i32 0, ptr %[[C_REAL_PTR]], align 4
1536+
// OGCG: store i32 3, ptr %[[C_IMAG_PTR]], align 4

0 commit comments

Comments
 (0)