1 // RUN: %clang_cc1 %s -emit-llvm -ffp-exception-behavior=maytrap -o - -triple arm64-none-linux-gnu | FileCheck %s
3 // Test that the constrained intrinsics are picking up the exception
4 // metadata from the AST instead of the global default from the command line.
6 #pragma float_control(except, on)
8 int printf(const char *, ...);
12 // CHECK-NEXT: [[STR_ADDR:%.*]] = alloca ptr, align 8
13 // CHECK-NEXT: [[X_ADDR:%.*]] = alloca i32, align 4
14 // CHECK-NEXT: store ptr [[STR:%.*]], ptr [[STR_ADDR]], align 8
15 // CHECK-NEXT: store i32 [[X:%.*]], ptr [[X_ADDR]], align 4
16 // CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[STR_ADDR]], align 8
17 // CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[X_ADDR]], align 4
18 // CHECK-NEXT: [[CALL:%.*]] = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef [[TMP0]], i32 noundef [[TMP1]]) [[ATTR4:#.*]]
19 // CHECK-NEXT: ret void
21 void p(char *str
, int x
) {
22 printf("%s: %d\n", str
, x
);
25 #define P(n,args) p(#n #args, __builtin_##n args)
27 // CHECK-LABEL: @test_long_double_isinf(
29 // CHECK-NEXT: [[LD_ADDR:%.*]] = alloca fp128, align 16
30 // CHECK-NEXT: store fp128 [[D:%.*]], ptr [[LD_ADDR]], align 16
31 // CHECK-NEXT: [[TMP0:%.*]] = load fp128, ptr [[LD_ADDR]], align 16
32 // CHECK-NEXT: [[TMP1:%.*]] = call i1 @llvm.is.fpclass.f128(fp128 [[TMP0]], i32 516)
33 // CHECK-NEXT: [[RES:%.*]] = zext i1 [[TMP1]] to i32
34 // CHECK-NEXT: call void @p(ptr noundef @.str.[[#STRID:1]], i32 noundef [[RES]]) [[ATTR4]]
35 // CHECK-NEXT: ret void
37 void test_long_double_isinf(long double ld
) {
43 // CHECK-LABEL: @test_long_double_isfinite(
45 // CHECK-NEXT: [[LD_ADDR:%.*]] = alloca fp128, align 16
46 // CHECK-NEXT: store fp128 [[D:%.*]], ptr [[LD_ADDR]], align 16
47 // CHECK-NEXT: [[TMP0:%.*]] = load fp128, ptr [[LD_ADDR]], align 16
48 // CHECK-NEXT: [[TMP1:%.*]] = call i1 @llvm.is.fpclass.f128(fp128 [[TMP0]], i32 504)
49 // CHECK-NEXT: [[RES:%.*]] = zext i1 [[TMP1]] to i32
50 // CHECK-NEXT: call void @p(ptr noundef @.str.[[#STRID:STRID+1]], i32 noundef [[RES]]) [[ATTR4]]
51 // CHECK-NEXT: ret void
53 void test_long_double_isfinite(long double ld
) {
59 // CHECK-LABEL: @test_long_double_isnan(
61 // CHECK-NEXT: [[LD_ADDR:%.*]] = alloca fp128, align 16
62 // CHECK-NEXT: store fp128 [[D:%.*]], ptr [[LD_ADDR]], align 16
63 // CHECK-NEXT: [[TMP0:%.*]] = load fp128, ptr [[LD_ADDR]], align 16
64 // CHECK-NEXT: [[TMP1:%.*]] = call i1 @llvm.is.fpclass.f128(fp128 [[TMP0]], i32 3)
65 // CHECK-NEXT: [[RES:%.*]] = zext i1 [[TMP1]] to i32
66 // CHECK-NEXT: call void @p(ptr noundef @.str.[[#STRID:STRID+1]], i32 noundef [[RES]])
67 // CHECK-NEXT: ret void
69 void test_long_double_isnan(long double ld
) {