brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.0 KiB · 73f6402 Raw
79 lines · c
1// RUN: %clang_cc1 -x c -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir %s -o %t.cir2// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR3// RUN: %clang_cc1 -x c -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm %s -o %t-cir.ll4// RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM5// RUN: %clang_cc1 -x c -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm %s -o %t.ll6// RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG7 8void foo2() {9  float _Complex a;10  float _Complex b;11  float _Complex c = a ?: b;12}13 14// CIR: %[[A_ADDR:.*]] = cir.alloca !cir.complex<!cir.float>, !cir.ptr<!cir.complex<!cir.float>>, ["a"]15// CIR: %[[B_ADDR:.*]] = cir.alloca !cir.complex<!cir.float>, !cir.ptr<!cir.complex<!cir.float>>, ["b"]16// CIR: %[[C_ADDR:.*]] = cir.alloca !cir.complex<!cir.float>, !cir.ptr<!cir.complex<!cir.float>>, ["c", init]17// CIR: %[[TMP_A:.*]] = cir.load{{.*}} %[[A_ADDR]] : !cir.ptr<!cir.complex<!cir.float>>, !cir.complex<!cir.float>18// CIR: %[[A_REAL:.*]] = cir.complex.real %[[TMP_A]] : !cir.complex<!cir.float> -> !cir.float19// CIR: %[[A_IMAG:.*]] = cir.complex.imag %[[TMP_A]] : !cir.complex<!cir.float> -> !cir.float20// CIR: %[[A_REAL_BOOL:.*]] = cir.cast float_to_bool %[[A_REAL]] : !cir.float -> !cir.bool21// CIR: %[[A_IMAG_BOOL:.*]] = cir.cast float_to_bool %[[A_IMAG]] : !cir.float -> !cir.bool22// CIR: %[[CONST_TRUE:.*]] = cir.const #true23// CIR: %[[COND:.*]] = cir.select if %[[A_REAL_BOOL]] then %[[CONST_TRUE]] else %[[A_IMAG_BOOL]] : (!cir.bool, !cir.bool, !cir.bool) -> !cir.bool24// CIR: %[[RESULT:.*]] = cir.ternary(%[[COND]], true {25// CIR:   cir.yield %[[TMP_A]] : !cir.complex<!cir.float>26// CIR: }, false {27// CIR:   %[[TMP_B:.*]] = cir.load{{.*}} %[[B_ADDR]] : !cir.ptr<!cir.complex<!cir.float>>, !cir.complex<!cir.float>28// CIR:   cir.yield %[[TMP_B]] : !cir.complex<!cir.float>29// CIR: }) : (!cir.bool) -> !cir.complex<!cir.float>30// CIR: cir.store{{.*}} %[[RESULT]], %[[C_ADDR]] : !cir.complex<!cir.float>, !cir.ptr<!cir.complex<!cir.float>>31 32// LLVM: %[[A_ADDR:.*]] = alloca { float, float }, i64 1, align 433// LLVM: %[[B_ADDR:.*]] = alloca { float, float }, i64 1, align 434// LLVM: %[[C_ADDR:.*]] = alloca { float, float }, i64 1, align 435// LLVM: %[[TMP_A:.*]] = load { float, float }, ptr %[[A_ADDR]], align 436// LLVM: %[[A_REAL:.*]] = extractvalue { float, float } %[[TMP_A]], 037// LLVM: %[[A_IMAG:.*]] = extractvalue { float, float } %[[TMP_A]], 138// LLVM: %[[A_REAL_BOOL:.*]] = fcmp une float %[[A_REAL]], 0.000000e+0039// LLVM: %[[A_IMAG_BOOL:.*]] = fcmp une float %[[A_IMAG]], 0.000000e+0040// LLVM: %[[COND:.*]] = or i1 %[[A_REAL_BOOL]], %[[A_IMAG_BOOL]]41// LLVM: br i1 %[[COND]], label %[[COND_TRUE:.*]], label %[[COND_FALSE:.*]]42// LLVM: [[COND_TRUE]]:43// LLVM:  br label %[[COND_RESULT:.*]]44// LLVM: [[COND_FALSE]]:45// LLVM:  %[[TMP_B:.*]] = load { float, float }, ptr %[[B_ADDR]], align 446// LLVM:  br label %[[COND_RESULT]]47// LLVM: [[COND_RESULT]]:48// LLVM:  %[[RESULT:.*]] = phi { float, float } [ %[[TMP_B]], %[[COND_FALSE]] ], [ %[[TMP_A]], %[[COND_TRUE]] ]49// LLVM:  br label %[[COND_END:.*]]50// LLVM: [[COND_END]]:51// LLVM:  store { float, float } %[[RESULT]], ptr %[[C_ADDR]], align 452 53// OGCG: %[[A_ADDR:.*]] = alloca { float, float }, align 454// OGCG: %[[B_ADDR:.*]] = alloca { float, float }, align 455// OGCG: %[[C_ADDR:.*]] = alloca { float, float }, align 456// OGCG: %[[A_REAL_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[A_ADDR]], i32 0, i32 057// OGCG: %[[A_REAL:.*]] = load float, ptr %[[A_REAL_PTR]], align 458// OGCG: %[[A_IMAG_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[A_ADDR]], i32 0, i32 159// OGCG: %[[A_IMAG:.*]] = load float, ptr %[[A_IMAG_PTR]], align 460// OGCG: %[[A_REAL_BOOL:.*]] = fcmp une float %[[A_REAL]], 0.000000e+0061// OGCG: %[[A_IMAG_BOOL:.*]] = fcmp une float %[[A_IMAG]], 0.000000e+0062// OGCG: %[[COND:.*]] = or i1 %[[A_REAL_BOOL]], %[[A_IMAG_BOOL]]63// OGCG: br i1 %tobool2, label %[[COND_TRUE:.*]], label %[[COND_FALSE:.*]]64// OGCG: [[COND_TRUE]]:65// OGCG:  br label %[[COND_END:.*]]66// OGCG: [[COND_FALSE]]:67// OGCG:  %[[B_REAL_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[B_ADDR]], i32 0, i32 068// OGCG:  %[[B_REAL:.*]] = load float, ptr %[[B_REAL_PTR]], align 469// OGCG:  %[[B_IMAG_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[B_ADDR]], i32 0, i32 170// OGCG:  %[[B_IMAG:.*]] = load float, ptr %[[B_IMAG_PTR]], align 471// OGCG:  br label %[[COND_END]]72// OGCG: [[COND_END]]:73// OGCG:  %[[RESULT_REAL:.*]] = phi float [ %[[A_REAL]], %[[COND_TRUE]] ], [ %[[B_REAL]], %[[COND_FALSE]] ]74// OGCG:  %[[RESULT_IMAG:.*]] = phi float [ %[[A_IMAG]], %[[COND_TRUE]] ], [ %[[B_IMAG]], %[[COND_FALSE]] ]75// OGCG:  %[[C_REAL_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[C_ADDR]], i32 0, i32 076// OGCG:  %[[C_IMAG_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[C_ADDR]], i32 0, i32 177// OGCG:  store float %[[RESULT_REAL]], ptr %[[C_REAL_PTR]], align 478// OGCG:  store float %[[RESULT_IMAG]], ptr %[[C_IMAG_PTR]], align 479