2016-07-14 03:42:06 +08:00
|
|
|
; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -strict-whitespace -check-prefix=SI -check-prefix=FUNC %s
|
2017-01-25 06:02:15 +08:00
|
|
|
; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -strict-whitespace -check-prefix=SI -check-prefix=FUNC %s
|
2014-06-19 12:24:43 +08:00
|
|
|
; RUN: llc -march=r600 -mcpu=cypress -verify-machineinstrs < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
|
|
|
|
|
2014-11-14 03:49:04 +08:00
|
|
|
declare float @llvm.fabs.f32(float) nounwind readnone
|
2014-06-19 12:24:43 +08:00
|
|
|
declare float @llvm.AMDGPU.clamp.f32(float, float, float) nounwind readnone
|
|
|
|
|
2014-10-02 01:15:17 +08:00
|
|
|
; FUNC-LABEL: {{^}}clamp_0_1_f32:
|
2014-11-05 22:50:53 +08:00
|
|
|
; SI: s_load_dword [[ARG:s[0-9]+]],
|
2016-09-09 01:19:29 +08:00
|
|
|
; SI: v_add_f32_e64 [[RESULT:v[0-9]+]], [[ARG]], 0 clamp{{$}}
|
2014-11-05 22:50:53 +08:00
|
|
|
; SI: buffer_store_dword [[RESULT]]
|
|
|
|
; SI: s_endpgm
|
2014-06-19 12:24:43 +08:00
|
|
|
|
|
|
|
; EG: MOV_SAT
|
|
|
|
define void @clamp_0_1_f32(float addrspace(1)* %out, float %src) nounwind {
|
|
|
|
%clamp = call float @llvm.AMDGPU.clamp.f32(float %src, float 0.0, float 1.0) nounwind readnone
|
|
|
|
store float %clamp, float addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-11-14 03:49:04 +08:00
|
|
|
; FUNC-LABEL: {{^}}clamp_fabs_0_1_f32:
|
|
|
|
; SI: s_load_dword [[ARG:s[0-9]+]],
|
2016-09-09 01:19:29 +08:00
|
|
|
; SI: v_add_f32_e64 [[RESULT:v[0-9]+]], |[[ARG]]|, 0 clamp{{$}}
|
2014-11-14 03:49:04 +08:00
|
|
|
; SI: buffer_store_dword [[RESULT]]
|
|
|
|
; SI: s_endpgm
|
|
|
|
define void @clamp_fabs_0_1_f32(float addrspace(1)* %out, float %src) nounwind {
|
|
|
|
%src.fabs = call float @llvm.fabs.f32(float %src) nounwind readnone
|
|
|
|
%clamp = call float @llvm.AMDGPU.clamp.f32(float %src.fabs, float 0.0, float 1.0) nounwind readnone
|
|
|
|
store float %clamp, float addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FUNC-LABEL: {{^}}clamp_fneg_0_1_f32:
|
|
|
|
; SI: s_load_dword [[ARG:s[0-9]+]],
|
2016-09-09 01:19:29 +08:00
|
|
|
; SI: v_add_f32_e64 [[RESULT:v[0-9]+]], -[[ARG]], 0 clamp{{$}}
|
2014-11-14 03:49:04 +08:00
|
|
|
; SI: buffer_store_dword [[RESULT]]
|
|
|
|
; SI: s_endpgm
|
|
|
|
define void @clamp_fneg_0_1_f32(float addrspace(1)* %out, float %src) nounwind {
|
|
|
|
%src.fneg = fsub float -0.0, %src
|
|
|
|
%clamp = call float @llvm.AMDGPU.clamp.f32(float %src.fneg, float 0.0, float 1.0) nounwind readnone
|
|
|
|
store float %clamp, float addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FUNC-LABEL: {{^}}clamp_fneg_fabs_0_1_f32:
|
|
|
|
; SI: s_load_dword [[ARG:s[0-9]+]],
|
2016-09-09 01:19:29 +08:00
|
|
|
; SI: v_add_f32_e64 [[RESULT:v[0-9]+]], -|[[ARG]]|, 0 clamp{{$}}
|
2014-11-14 03:49:04 +08:00
|
|
|
; SI: buffer_store_dword [[RESULT]]
|
|
|
|
; SI: s_endpgm
|
|
|
|
define void @clamp_fneg_fabs_0_1_f32(float addrspace(1)* %out, float %src) nounwind {
|
|
|
|
%src.fabs = call float @llvm.fabs.f32(float %src) nounwind readnone
|
|
|
|
%src.fneg.fabs = fsub float -0.0, %src.fabs
|
|
|
|
%clamp = call float @llvm.AMDGPU.clamp.f32(float %src.fneg.fabs, float 0.0, float 1.0) nounwind readnone
|
|
|
|
store float %clamp, float addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|