| 1 |
// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir |
| 2 |
// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR |
| 3 |
// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-linux-gnu -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++23 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll |
| 6 |
// RUN: FileCheck --input-file=%t.ll %s --check-prefix=OGCG |
| 7 |
|
| 8 |
void f() { |
| 9 |
int result = 0; |
| 10 |
|
| 11 |
if consteval { |
| 12 |
result = 10; |
| 13 |
// CIR-NOT: cir.const #cir.int<10> : !s32i |
| 14 |
// LLVM-NOT: store i32 10 |
| 15 |
// OGCG-NOT: store i32 10 |
| 16 |
} else { |
| 17 |
result = 20; |
| 18 |
// CHECK: cir.const #cir.int<20> : !s32i |
| 19 |
// LLVM: store i32 20, ptr %1, align 4 |
| 20 |
// OGCG: store i32 20, ptr %result, align 4 |
| 21 |
|
| 22 |
} |
| 23 |
|
| 24 |
if !consteval { |
| 25 |
result = 30; |
| 26 |
// CIR: cir.const #cir.int<30> : !s32i |
| 27 |
// LLVM: store i32 30, ptr %1, align 4 |
| 28 |
// OGCG: store i32 30, ptr %result, align 4 |
| 29 |
} else { |
| 30 |
result = 40; |
| 31 |
// CIR-NOT: cir.const #cir.int<40> : !s32i |
| 32 |
// LLVM-NOT: store i32 40 |
| 33 |
// OGCG-NOT: store i32 40 |
| 34 |
} |
| 35 |
|
| 36 |
if consteval { |
| 37 |
result = 50; |
| 38 |
// CIR-NOT: cir.const #cir.int<50> : !s32i |
| 39 |
// LLVM-NOT: store i32 50 |
| 40 |
// OGCG-NOT: store i32 50 |
| 41 |
} |
| 42 |
|
| 43 |
if !consteval { |
| 44 |
result = 60; |
| 45 |
// CIR: cir.const #cir.int<60> : !s32i |
| 46 |
// LLVM: store i32 60, ptr %1, align 4 |
| 47 |
// OGCG: store i32 60, ptr %result, align 4 |
| 48 |
} |
| 49 |
|
| 50 |
} |