1// REQUIRES: r600-registered-target 2// RUN: %clang_cc1 -triple r600-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s 3// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s 4 5#pragma OPENCL EXTENSION cl_khr_fp64 : enable 6 7// CHECK-LABEL: @test_div_scale_f64 8// CHECK: call { double, i1 } @llvm.AMDGPU.div.scale.f64(double %a, double %b, i1 true) 9// CHECK-DAG: [[FLAG:%.+]] = extractvalue { double, i1 } %{{.+}}, 1 10// CHECK-DAG: [[VAL:%.+]] = extractvalue { double, i1 } %{{.+}}, 0 11// CHECK: [[FLAGEXT:%.+]] = zext i1 [[FLAG]] to i32 12// CHECK: store i32 [[FLAGEXT]] 13void test_div_scale_f64(global double* out, global int* flagout, double a, double b) 14{ 15 bool flag; 16 *out = __builtin_amdgpu_div_scale(a, b, true, &flag); 17 *flagout = flag; 18} 19 20// CHECK-LABEL: @test_div_scale_f32 21// CHECK: call { float, i1 } @llvm.AMDGPU.div.scale.f32(float %a, float %b, i1 true) 22// CHECK-DAG: [[FLAG:%.+]] = extractvalue { float, i1 } %{{.+}}, 1 23// CHECK-DAG: [[VAL:%.+]] = extractvalue { float, i1 } %{{.+}}, 0 24// CHECK: [[FLAGEXT:%.+]] = zext i1 [[FLAG]] to i32 25// CHECK: store i32 [[FLAGEXT]] 26void test_div_scale_f32(global float* out, global int* flagout, float a, float b) 27{ 28 bool flag; 29 *out = __builtin_amdgpu_div_scalef(a, b, true, &flag); 30 *flagout = flag; 31} 32 33// CHECK-LABEL: @test_div_fmas_f32 34// CHECK: call float @llvm.AMDGPU.div.fmas.f32 35void test_div_fmas_f32(global float* out, float a, float b, float c, int d) 36{ 37 *out = __builtin_amdgpu_div_fmasf(a, b, c, d); 38} 39 40// CHECK-LABEL: @test_div_fmas_f64 41// CHECK: call double @llvm.AMDGPU.div.fmas.f64 42void test_div_fmas_f64(global double* out, double a, double b, double c, int d) 43{ 44 *out = __builtin_amdgpu_div_fmas(a, b, c, d); 45} 46 47// CHECK-LABEL: @test_div_fixup_f32 48// CHECK: call float @llvm.AMDGPU.div.fixup.f32 49void test_div_fixup_f32(global float* out, float a, float b, float c) 50{ 51 *out = __builtin_amdgpu_div_fixupf(a, b, c); 52} 53 54// CHECK-LABEL: @test_div_fixup_f64 55// CHECK: call double @llvm.AMDGPU.div.fixup.f64 56void test_div_fixup_f64(global double* out, double a, double b, double c) 57{ 58 *out = __builtin_amdgpu_div_fixup(a, b, c); 59} 60 61// CHECK-LABEL: @test_trig_preop_f32 62// CHECK: call float @llvm.AMDGPU.trig.preop.f32 63void test_trig_preop_f32(global float* out, float a, int b) 64{ 65 *out = __builtin_amdgpu_trig_preopf(a, b); 66} 67 68// CHECK-LABEL: @test_trig_preop_f64 69// CHECK: call double @llvm.AMDGPU.trig.preop.f64 70void test_trig_preop_f64(global double* out, double a, int b) 71{ 72 *out = __builtin_amdgpu_trig_preop(a, b); 73} 74 75// CHECK-LABEL: @test_rcp_f32 76// CHECK: call float @llvm.AMDGPU.rcp.f32 77void test_rcp_f32(global float* out, float a) 78{ 79 *out = __builtin_amdgpu_rcpf(a); 80} 81 82// CHECK-LABEL: @test_rcp_f64 83// CHECK: call double @llvm.AMDGPU.rcp.f64 84void test_rcp_f64(global double* out, double a) 85{ 86 *out = __builtin_amdgpu_rcp(a); 87} 88 89// CHECK-LABEL: @test_rsq_f32 90// CHECK: call float @llvm.AMDGPU.rsq.f32 91void test_rsq_f32(global float* out, float a) 92{ 93 *out = __builtin_amdgpu_rsqf(a); 94} 95 96// CHECK-LABEL: @test_rsq_f64 97// CHECK: call double @llvm.AMDGPU.rsq.f64 98void test_rsq_f64(global double* out, double a) 99{ 100 *out = __builtin_amdgpu_rsq(a); 101} 102 103// CHECK-LABEL: @test_rsq_clamped_f32 104// CHECK: call float @llvm.AMDGPU.rsq.clamped.f32 105void test_rsq_clamped_f32(global float* out, float a) 106{ 107 *out = __builtin_amdgpu_rsq_clampedf(a); 108} 109 110// CHECK-LABEL: @test_rsq_clamped_f64 111// CHECK: call double @llvm.AMDGPU.rsq.clamped.f64 112void test_rsq_clamped_f64(global double* out, double a) 113{ 114 *out = __builtin_amdgpu_rsq_clamped(a); 115} 116 117// CHECK-LABEL: @test_ldexp_f32 118// CHECK: call float @llvm.AMDGPU.ldexp.f32 119void test_ldexp_f32(global float* out, float a, int b) 120{ 121 *out = __builtin_amdgpu_ldexpf(a, b); 122} 123 124// CHECK-LABEL: @test_ldexp_f64 125// CHECK: call double @llvm.AMDGPU.ldexp.f64 126void test_ldexp_f64(global double* out, double a, int b) 127{ 128 *out = __builtin_amdgpu_ldexp(a, b); 129} 130 131// CHECK-LABEL: @test_class_f32 132// CHECK: call i1 @llvm.AMDGPU.class.f32 133void test_class_f32(global float* out, float a, int b) 134{ 135 *out = __builtin_amdgpu_classf(a, b); 136} 137 138// CHECK-LABEL: @test_class_f64 139// CHECK: call i1 @llvm.AMDGPU.class.f64 140void test_class_f64(global double* out, double a, int b) 141{ 142 *out = __builtin_amdgpu_class(a, b); 143} 144