2014-08-29 16:01:14 +00:00
|
|
|
; RUN: llc -march=r600 -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
|
|
|
|
|
|
|
|
declare i32 @llvm.r600.read.tidig.x() #0
|
|
|
|
declare float @llvm.fabs.f32(float) #0
|
|
|
|
|
2014-10-01 17:15:17 +00:00
|
|
|
; FUNC-LABEL: {{^}}mad_sub_f32:
|
2014-11-05 14:50:53 +00:00
|
|
|
; SI: buffer_load_dword [[REGA:v[0-9]+]]
|
|
|
|
; SI: buffer_load_dword [[REGB:v[0-9]+]]
|
|
|
|
; SI: buffer_load_dword [[REGC:v[0-9]+]]
|
|
|
|
; SI: v_mad_f32 [[RESULT:v[0-9]+]], [[REGA]], [[REGB]], -[[REGC]]
|
|
|
|
; SI: buffer_store_dword [[RESULT]]
|
2014-08-29 16:01:14 +00:00
|
|
|
define void @mad_sub_f32(float addrspace(1)* noalias nocapture %out, float addrspace(1)* noalias nocapture readonly %ptr) #1 {
|
|
|
|
%tid = tail call i32 @llvm.r600.read.tidig.x() #0
|
|
|
|
%tid.ext = sext i32 %tid to i64
|
|
|
|
%gep0 = getelementptr float addrspace(1)* %ptr, i64 %tid.ext
|
|
|
|
%add1 = add i64 %tid.ext, 1
|
|
|
|
%gep1 = getelementptr float addrspace(1)* %ptr, i64 %add1
|
|
|
|
%add2 = add i64 %tid.ext, 2
|
|
|
|
%gep2 = getelementptr float addrspace(1)* %ptr, i64 %add2
|
|
|
|
%outgep = getelementptr float addrspace(1)* %out, i64 %tid.ext
|
|
|
|
%a = load float addrspace(1)* %gep0, align 4
|
|
|
|
%b = load float addrspace(1)* %gep1, align 4
|
|
|
|
%c = load float addrspace(1)* %gep2, align 4
|
|
|
|
%mul = fmul float %a, %b
|
|
|
|
%sub = fsub float %mul, %c
|
|
|
|
store float %sub, float addrspace(1)* %outgep, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-01 17:15:17 +00:00
|
|
|
; FUNC-LABEL: {{^}}mad_sub_inv_f32:
|
2014-11-05 14:50:53 +00:00
|
|
|
; SI: buffer_load_dword [[REGA:v[0-9]+]]
|
|
|
|
; SI: buffer_load_dword [[REGB:v[0-9]+]]
|
|
|
|
; SI: buffer_load_dword [[REGC:v[0-9]+]]
|
|
|
|
; SI: v_mad_f32 [[RESULT:v[0-9]+]], -[[REGA]], [[REGB]], [[REGC]]
|
|
|
|
; SI: buffer_store_dword [[RESULT]]
|
2014-08-29 16:01:14 +00:00
|
|
|
define void @mad_sub_inv_f32(float addrspace(1)* noalias nocapture %out, float addrspace(1)* noalias nocapture readonly %ptr) #1 {
|
|
|
|
%tid = tail call i32 @llvm.r600.read.tidig.x() #0
|
|
|
|
%tid.ext = sext i32 %tid to i64
|
|
|
|
%gep0 = getelementptr float addrspace(1)* %ptr, i64 %tid.ext
|
|
|
|
%add1 = add i64 %tid.ext, 1
|
|
|
|
%gep1 = getelementptr float addrspace(1)* %ptr, i64 %add1
|
|
|
|
%add2 = add i64 %tid.ext, 2
|
|
|
|
%gep2 = getelementptr float addrspace(1)* %ptr, i64 %add2
|
|
|
|
%outgep = getelementptr float addrspace(1)* %out, i64 %tid.ext
|
|
|
|
%a = load float addrspace(1)* %gep0, align 4
|
|
|
|
%b = load float addrspace(1)* %gep1, align 4
|
|
|
|
%c = load float addrspace(1)* %gep2, align 4
|
|
|
|
%mul = fmul float %a, %b
|
|
|
|
%sub = fsub float %c, %mul
|
|
|
|
store float %sub, float addrspace(1)* %outgep, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-01 17:15:17 +00:00
|
|
|
; FUNC-LABEL: {{^}}mad_sub_f64:
|
2014-11-05 14:50:53 +00:00
|
|
|
; SI: v_mul_f64
|
|
|
|
; SI: v_add_f64
|
2014-08-29 16:01:14 +00:00
|
|
|
define void @mad_sub_f64(double addrspace(1)* noalias nocapture %out, double addrspace(1)* noalias nocapture readonly %ptr) #1 {
|
|
|
|
%tid = tail call i32 @llvm.r600.read.tidig.x() #0
|
|
|
|
%tid.ext = sext i32 %tid to i64
|
|
|
|
%gep0 = getelementptr double addrspace(1)* %ptr, i64 %tid.ext
|
|
|
|
%add1 = add i64 %tid.ext, 1
|
|
|
|
%gep1 = getelementptr double addrspace(1)* %ptr, i64 %add1
|
|
|
|
%add2 = add i64 %tid.ext, 2
|
|
|
|
%gep2 = getelementptr double addrspace(1)* %ptr, i64 %add2
|
|
|
|
%outgep = getelementptr double addrspace(1)* %out, i64 %tid.ext
|
|
|
|
%a = load double addrspace(1)* %gep0, align 8
|
|
|
|
%b = load double addrspace(1)* %gep1, align 8
|
|
|
|
%c = load double addrspace(1)* %gep2, align 8
|
|
|
|
%mul = fmul double %a, %b
|
|
|
|
%sub = fsub double %mul, %c
|
|
|
|
store double %sub, double addrspace(1)* %outgep, align 8
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-01 17:15:17 +00:00
|
|
|
; FUNC-LABEL: {{^}}mad_sub_fabs_f32:
|
2014-11-05 14:50:53 +00:00
|
|
|
; SI: buffer_load_dword [[REGA:v[0-9]+]]
|
|
|
|
; SI: buffer_load_dword [[REGB:v[0-9]+]]
|
|
|
|
; SI: buffer_load_dword [[REGC:v[0-9]+]]
|
|
|
|
; SI: v_mad_f32 [[RESULT:v[0-9]+]], [[REGA]], [[REGB]], -|[[REGC]]|
|
|
|
|
; SI: buffer_store_dword [[RESULT]]
|
2014-08-29 16:01:14 +00:00
|
|
|
define void @mad_sub_fabs_f32(float addrspace(1)* noalias nocapture %out, float addrspace(1)* noalias nocapture readonly %ptr) #1 {
|
|
|
|
%tid = tail call i32 @llvm.r600.read.tidig.x() #0
|
|
|
|
%tid.ext = sext i32 %tid to i64
|
|
|
|
%gep0 = getelementptr float addrspace(1)* %ptr, i64 %tid.ext
|
|
|
|
%add1 = add i64 %tid.ext, 1
|
|
|
|
%gep1 = getelementptr float addrspace(1)* %ptr, i64 %add1
|
|
|
|
%add2 = add i64 %tid.ext, 2
|
|
|
|
%gep2 = getelementptr float addrspace(1)* %ptr, i64 %add2
|
|
|
|
%outgep = getelementptr float addrspace(1)* %out, i64 %tid.ext
|
|
|
|
%a = load float addrspace(1)* %gep0, align 4
|
|
|
|
%b = load float addrspace(1)* %gep1, align 4
|
|
|
|
%c = load float addrspace(1)* %gep2, align 4
|
|
|
|
%c.abs = call float @llvm.fabs.f32(float %c) #0
|
|
|
|
%mul = fmul float %a, %b
|
|
|
|
%sub = fsub float %mul, %c.abs
|
|
|
|
store float %sub, float addrspace(1)* %outgep, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-01 17:15:17 +00:00
|
|
|
; FUNC-LABEL: {{^}}mad_sub_fabs_inv_f32:
|
2014-11-05 14:50:53 +00:00
|
|
|
; SI: buffer_load_dword [[REGA:v[0-9]+]]
|
|
|
|
; SI: buffer_load_dword [[REGB:v[0-9]+]]
|
|
|
|
; SI: buffer_load_dword [[REGC:v[0-9]+]]
|
|
|
|
; SI: v_mad_f32 [[RESULT:v[0-9]+]], -[[REGA]], [[REGB]], |[[REGC]]|
|
|
|
|
; SI: buffer_store_dword [[RESULT]]
|
2014-08-29 16:01:14 +00:00
|
|
|
define void @mad_sub_fabs_inv_f32(float addrspace(1)* noalias nocapture %out, float addrspace(1)* noalias nocapture readonly %ptr) #1 {
|
|
|
|
%tid = tail call i32 @llvm.r600.read.tidig.x() #0
|
|
|
|
%tid.ext = sext i32 %tid to i64
|
|
|
|
%gep0 = getelementptr float addrspace(1)* %ptr, i64 %tid.ext
|
|
|
|
%add1 = add i64 %tid.ext, 1
|
|
|
|
%gep1 = getelementptr float addrspace(1)* %ptr, i64 %add1
|
|
|
|
%add2 = add i64 %tid.ext, 2
|
|
|
|
%gep2 = getelementptr float addrspace(1)* %ptr, i64 %add2
|
|
|
|
%outgep = getelementptr float addrspace(1)* %out, i64 %tid.ext
|
|
|
|
%a = load float addrspace(1)* %gep0, align 4
|
|
|
|
%b = load float addrspace(1)* %gep1, align 4
|
|
|
|
%c = load float addrspace(1)* %gep2, align 4
|
|
|
|
%c.abs = call float @llvm.fabs.f32(float %c) #0
|
|
|
|
%mul = fmul float %a, %b
|
|
|
|
%sub = fsub float %c.abs, %mul
|
|
|
|
store float %sub, float addrspace(1)* %outgep, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-01 17:15:17 +00:00
|
|
|
; FUNC-LABEL: {{^}}neg_neg_mad_f32:
|
2014-11-05 14:50:53 +00:00
|
|
|
; SI: v_mad_f32 {{v[0-9]+}}, {{v[0-9]+}}, {{v[0-9]+}}, {{v[0-9]+}}
|
2014-08-29 16:01:14 +00:00
|
|
|
define void @neg_neg_mad_f32(float addrspace(1)* noalias nocapture %out, float addrspace(1)* noalias nocapture readonly %ptr) #1 {
|
|
|
|
%tid = tail call i32 @llvm.r600.read.tidig.x() #0
|
|
|
|
%tid.ext = sext i32 %tid to i64
|
|
|
|
%gep0 = getelementptr float addrspace(1)* %ptr, i64 %tid.ext
|
|
|
|
%add1 = add i64 %tid.ext, 1
|
|
|
|
%gep1 = getelementptr float addrspace(1)* %ptr, i64 %add1
|
|
|
|
%add2 = add i64 %tid.ext, 2
|
|
|
|
%gep2 = getelementptr float addrspace(1)* %ptr, i64 %add2
|
|
|
|
%outgep = getelementptr float addrspace(1)* %out, i64 %tid.ext
|
|
|
|
%a = load float addrspace(1)* %gep0, align 4
|
|
|
|
%b = load float addrspace(1)* %gep1, align 4
|
|
|
|
%c = load float addrspace(1)* %gep2, align 4
|
|
|
|
%nega = fsub float -0.000000e+00, %a
|
|
|
|
%negb = fsub float -0.000000e+00, %b
|
|
|
|
%mul = fmul float %nega, %negb
|
|
|
|
%sub = fadd float %mul, %c
|
|
|
|
store float %sub, float addrspace(1)* %outgep, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-01 17:15:17 +00:00
|
|
|
; FUNC-LABEL: {{^}}mad_fabs_sub_f32:
|
2014-11-05 14:50:53 +00:00
|
|
|
; SI: buffer_load_dword [[REGA:v[0-9]+]]
|
|
|
|
; SI: buffer_load_dword [[REGB:v[0-9]+]]
|
|
|
|
; SI: buffer_load_dword [[REGC:v[0-9]+]]
|
|
|
|
; SI: v_mad_f32 [[RESULT:v[0-9]+]], [[REGA]], |[[REGB]]|, -[[REGC]]
|
|
|
|
; SI: buffer_store_dword [[RESULT]]
|
2014-08-29 16:01:14 +00:00
|
|
|
define void @mad_fabs_sub_f32(float addrspace(1)* noalias nocapture %out, float addrspace(1)* noalias nocapture readonly %ptr) #1 {
|
|
|
|
%tid = tail call i32 @llvm.r600.read.tidig.x() #0
|
|
|
|
%tid.ext = sext i32 %tid to i64
|
|
|
|
%gep0 = getelementptr float addrspace(1)* %ptr, i64 %tid.ext
|
|
|
|
%add1 = add i64 %tid.ext, 1
|
|
|
|
%gep1 = getelementptr float addrspace(1)* %ptr, i64 %add1
|
|
|
|
%add2 = add i64 %tid.ext, 2
|
|
|
|
%gep2 = getelementptr float addrspace(1)* %ptr, i64 %add2
|
|
|
|
%outgep = getelementptr float addrspace(1)* %out, i64 %tid.ext
|
|
|
|
%a = load float addrspace(1)* %gep0, align 4
|
|
|
|
%b = load float addrspace(1)* %gep1, align 4
|
|
|
|
%c = load float addrspace(1)* %gep2, align 4
|
|
|
|
%b.abs = call float @llvm.fabs.f32(float %b) #0
|
|
|
|
%mul = fmul float %a, %b.abs
|
|
|
|
%sub = fsub float %mul, %c
|
|
|
|
store float %sub, float addrspace(1)* %outgep, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-01 17:15:17 +00:00
|
|
|
; FUNC-LABEL: {{^}}fsub_c_fadd_a_a:
|
2014-11-05 14:50:53 +00:00
|
|
|
; SI-DAG: buffer_load_dword [[R1:v[0-9]+]], {{v\[[0-9]+:[0-9]+\]}}, {{s\[[0-9]+:[0-9]+\]}}, 0 addr64{{$}}
|
2014-12-03 03:12:13 +00:00
|
|
|
; SI-DAG: buffer_load_dword [[R2:v[0-9]+]], {{v\[[0-9]+:[0-9]+\]}}, {{s\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:4
|
2014-11-05 14:50:53 +00:00
|
|
|
; SI: v_mad_f32 [[RESULT:v[0-9]+]], -2.0, [[R1]], [[R2]]
|
|
|
|
; SI: buffer_store_dword [[RESULT]]
|
2014-09-29 14:59:38 +00:00
|
|
|
define void @fsub_c_fadd_a_a(float addrspace(1)* %out, float addrspace(1)* %in) {
|
|
|
|
%tid = call i32 @llvm.r600.read.tidig.x() nounwind readnone
|
|
|
|
%gep.0 = getelementptr float addrspace(1)* %out, i32 %tid
|
|
|
|
%gep.1 = getelementptr float addrspace(1)* %gep.0, i32 1
|
|
|
|
%gep.out = getelementptr float addrspace(1)* %out, i32 %tid
|
|
|
|
|
|
|
|
%r1 = load float addrspace(1)* %gep.0
|
|
|
|
%r2 = load float addrspace(1)* %gep.1
|
|
|
|
|
|
|
|
%add = fadd float %r1, %r1
|
|
|
|
%r3 = fsub float %r2, %add
|
|
|
|
|
|
|
|
store float %r3, float addrspace(1)* %gep.out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-01 17:15:17 +00:00
|
|
|
; FUNC-LABEL: {{^}}fsub_fadd_a_a_c:
|
2014-11-05 14:50:53 +00:00
|
|
|
; SI-DAG: buffer_load_dword [[R1:v[0-9]+]], {{v\[[0-9]+:[0-9]+\]}}, {{s\[[0-9]+:[0-9]+\]}}, 0 addr64{{$}}
|
2014-12-03 03:12:13 +00:00
|
|
|
; SI-DAG: buffer_load_dword [[R2:v[0-9]+]], {{v\[[0-9]+:[0-9]+\]}}, {{s\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:4
|
2014-11-05 14:50:53 +00:00
|
|
|
; SI: v_mad_f32 [[RESULT:v[0-9]+]], 2.0, [[R1]], -[[R2]]
|
|
|
|
; SI: buffer_store_dword [[RESULT]]
|
2014-09-29 14:59:38 +00:00
|
|
|
define void @fsub_fadd_a_a_c(float addrspace(1)* %out, float addrspace(1)* %in) {
|
|
|
|
%tid = call i32 @llvm.r600.read.tidig.x() nounwind readnone
|
|
|
|
%gep.0 = getelementptr float addrspace(1)* %out, i32 %tid
|
|
|
|
%gep.1 = getelementptr float addrspace(1)* %gep.0, i32 1
|
|
|
|
%gep.out = getelementptr float addrspace(1)* %out, i32 %tid
|
|
|
|
|
|
|
|
%r1 = load float addrspace(1)* %gep.0
|
|
|
|
%r2 = load float addrspace(1)* %gep.1
|
|
|
|
|
|
|
|
%add = fadd float %r1, %r1
|
|
|
|
%r3 = fsub float %add, %r2
|
|
|
|
|
|
|
|
store float %r3, float addrspace(1)* %gep.out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-08-29 16:01:14 +00:00
|
|
|
attributes #0 = { nounwind readnone }
|
|
|
|
attributes #1 = { nounwind }
|