[AMDGPU][True16][CodeGen] true16 codegen pattern for v_med3_u/i16 (#121850)
[llvm-project.git] / clang / test / CodeGenCXX / cxx23-assume.cpp
bloba1fa6b30b2f0e112298fe0433c3efc2d21260632
1 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++23 %s -emit-llvm -o - | FileCheck %s
2 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++23 -fno-assumptions %s -emit-llvm -o - | FileCheck %s --check-prefix=DISABLED
4 // DISABLED-NOT: @llvm.assume
6 bool f();
8 template <typename T>
9 void f2() {
10 [[assume(sizeof(T) == sizeof(int))]];
13 // CHECK: @_Z1gii(i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]])
14 // CHECK-NEXT: entry:
15 // CHECK-NEXT: [[X_ADDR:%.*]] = alloca i32
16 // CHECK-NEXT: [[Y_ADDR:%.*]] = alloca i32
17 // CHECK-NEXT: store i32 [[X]], ptr [[X_ADDR]]
18 // CHECK-NEXT: store i32 [[Y]], ptr [[Y_ADDR]]
19 void g(int x, int y) {
20 // Not emitted because it has side-effects.
21 [[assume(f())]];
23 // CHECK-NEXT: call void @llvm.assume(i1 true)
24 [[assume((1, 2))]];
26 // CHECK-NEXT: [[X1:%.*]] = load i32, ptr [[X_ADDR]]
27 // CHECK-NEXT: [[CMP1:%.*]] = icmp ne i32 [[X1]], 27
28 // CHECK-NEXT: call void @llvm.assume(i1 [[CMP1]])
29 [[assume(x != 27)]];
31 // CHECK-NEXT: [[X2:%.*]] = load i32, ptr [[X_ADDR]]
32 // CHECK-NEXT: [[Y2:%.*]] = load i32, ptr [[Y_ADDR]]
33 // CHECK-NEXT: [[CMP2:%.*]] = icmp eq i32 [[X2]], [[Y2]]
34 // CHECK-NEXT: call void @llvm.assume(i1 [[CMP2]])
35 [[assume(x == y)]];
37 // CHECK-NEXT: call void @_Z2f2IiEvv()
38 f2<int>();
40 // CHECK-NEXT: call void @_Z2f2IdEvv()
41 f2<double>();
44 // CHECK: void @_Z2f2IiEvv()
45 // CHECK-NEXT: entry:
46 // CHECK-NEXT: call void @llvm.assume(i1 true)
48 // CHECK: void @_Z2f2IdEvv()
49 // CHECK-NEXT: entry:
50 // CHECK-NEXT: call void @llvm.assume(i1 false)