Debian Codegraph @

clang/test/CIR/CodeGen/choose-expr.cpp

raw
1 // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir %s -o %t.cir
2 // RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
3 // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm %s -o %t-cir.ll
4 // RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM
5 // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm %s -o %t.ll
6 // RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG
7
8 void choose_expr() {
9 int a = __builtin_choose_expr(1, 2, 3);
10 }
11
12 // CIR: %[[A_ADDR:.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["a", init]
13 // CIR: %[[CONST_2:.*]] = cir.const #cir.int<2> : !s32i
14 // CIR: cir.store {{.*}} %[[CONST_2]], %[[A_ADDR]] : !s32i, !cir.ptr<!s32i>
15
16 // LLVM: %[[A_ADDR:.*]] = alloca i32, i64 1, align 4
17 // LLVM: store i32 2, ptr %[[A_ADDR]], align 4
18
19 // OGCG: %[[A_ADDR:.*]] = alloca i32, align 4
20 // OGCG: store i32 2, ptr %[[A_ADDR]], align 4
21
22 void choose_expr_non_constant() {
23 int a;
24 int b;
25 int c = __builtin_choose_expr(1, a, b);
26 }
27
28 // CIR: %[[A_ADDR:.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["a"]
29 // CIR: %[[B_ADDR:.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["b"]
30 // CIR: %[[C_ADDR:.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["c", init]
31 // CIR: %[[TMP_A:.*]] = cir.load {{.*}} %[[A_ADDR]] : !cir.ptr<!s32i>, !s32i
32 // CIR: cir.store {{.*}} %[[TMP_A]], %[[C_ADDR]] : !s32i, !cir.ptr<!s32i>
33
34 // LLVM: %[[A_ADDR:.*]] = alloca i32, i64 1, align 4
35 // LLVM: %[[B_ADDR:.*]] = alloca i32, i64 1, align 4
36 // LLVM: %[[C_ADDR:.*]] = alloca i32, i64 1, align 4
37 // LLVM: %[[TMP_A:.*]] = load i32, ptr %[[A_ADDR]], align 4
38 // LLVM: store i32 %[[TMP_A]], ptr %[[C_ADDR]], align 4
39
40 // OGCG: %[[A_ADDR:.*]] = alloca i32, align 4
41 // OGCG: %[[B_ADDR:.*]] = alloca i32, align 4
42 // OGCG: %[[C_ADDR:.*]] = alloca i32, align 4
43 // OGCG: %[[TMP_A:.*]] = load i32, ptr %[[A_ADDR]], align 4
44 // OGCG: store i32 %[[TMP_A]], ptr %[[C_ADDR]], align 4