xref: /llvm-project/llvm/test/CodeGen/DirectX/saturate.ll (revision 011b618644113996e2c0a8e57db40f89d20878e3)
1; RUN: opt -S -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s
2; Make sure the intrinsic dx.saturate is to appropriate DXIL op for half/float/double data types.
3
4; CHECK-LABEL: test_saturate_half
5define noundef half @test_saturate_half(half noundef %p0) {
6entry:
7  ; CHECK: call half @dx.op.unary.f16(i32 7, half %p0) #[[#ATTR:]]
8  %hlsl.saturate = call half @llvm.dx.saturate.f16(half %p0)
9  ; CHECK: ret half
10  ret half %hlsl.saturate
11}
12
13; CHECK-LABEL: test_saturate_float
14define noundef float @test_saturate_float(float noundef %p0) {
15entry:
16  ; CHECK: call float @dx.op.unary.f32(i32 7, float %p0) #[[#ATTR]]
17  %hlsl.saturate = call float @llvm.dx.saturate.f32(float %p0)
18  ; CHECK: ret float
19  ret float %hlsl.saturate
20}
21
22; CHECK-LABEL: test_saturate_double
23define noundef double @test_saturate_double(double noundef %p0) {
24entry:
25  ; CHECK: call double @dx.op.unary.f64(i32 7, double %p0) #[[#ATTR]]
26  %hlsl.saturate = call double @llvm.dx.saturate.f64(double %p0)
27  ; CHECK: ret double
28  ret double %hlsl.saturate
29}
30
31; CHECK: attributes #[[#ATTR]] = {{{.*}} memory(none) {{.*}}}
32
33declare half @llvm.dx.saturate.f16(half)
34declare float @llvm.dx.saturate.f32(float)
35declare double @llvm.dx.saturate.f64(double)
36
37