[LLVM][IR] Use splat syntax when printing ConstantExpr based splats. (#116856)
[llvm-project.git] / clang / test / CodeGen / builtin-assume.c
blob0c0a3211ed0b349ca7f32d036b1b3071fe0e7a2b
1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -triple i386-mingw32 -fms-extensions -emit-llvm -o - %s | FileCheck %s
4 int nonconst(void);
5 int isconst(void) __attribute__((const));
6 int ispure(void) __attribute__((pure));
8 // CHECK-LABEL: @test1
9 int test1(int *a, int i) {
10 // CHECK: store ptr %a, ptr [[A_ADDR:%.+]], align
11 // CHECK: [[A:%.+]] = load ptr, ptr [[A_ADDR]]
12 // CHECK: [[CMP:%.+]] = icmp ne ptr [[A]], null
13 // CHECK: call void @llvm.assume(i1 [[CMP]])
15 // CHECK: [[CALL:%.+]] = call i32 @isconst()
16 // CHECK: [[BOOL:%.+]] = icmp ne i32 [[CALL]], 0
17 // CHECK: call void @llvm.assume(i1 [[BOOL]])
19 // CHECK: [[CALLPURE:%.+]] = call i32 @ispure()
20 // CHECK: [[BOOLPURE:%.+]] = icmp ne i32 [[CALLPURE]], 0
21 // CHECK: call void @llvm.assume(i1 [[BOOLPURE]])
22 #ifdef _MSC_VER
23 __assume(a != 0)
24 __assume(isconst());
25 __assume(ispure());
26 #else
27 __builtin_assume(a != 0);
28 __builtin_assume(isconst());
29 __builtin_assume(ispure());
30 #endif
32 // Nothing is generated for an assume with side effects...
33 // CHECK-NOT: load ptr, ptr %i.addr
34 // CHECK-NOT: call void @llvm.assume
35 // CHECK-NOT: call i32 @nonconst()
36 #ifdef _MSC_VER
37 __assume(++i != 0)
38 __assume(nonconst());
39 #else
40 __builtin_assume(++i != 0);
41 __builtin_assume(nonconst());
42 #endif
44 return a[0];