blob: d77dd9216cd7e7695c323dd2a683210c8eb74048 [file] [log] [blame]
Mon P Wang95be6992009-01-31 06:50:54 +00001; RUN: llvm-as -o - %s | llc -march=cellspu -enable-unsafe-fp-math > %t1.s
Chris Lattner994d6cf2008-01-18 19:53:43 +00002; RUN: grep fa %t1.s | count 2
3; RUN: grep fs %t1.s | count 2
4; RUN: grep fm %t1.s | count 6
5; RUN: grep fma %t1.s | count 2
6; RUN: grep fms %t1.s | count 2
Scott Michel0a92af42007-12-19 20:50:49 +00007; RUN: grep fnms %t1.s | count 3
8;
9; This file includes standard floating point arithmetic instructions
10; NOTE fdiv is tested separately since it is a compound operation
Scott Michel9de5d0d2008-01-11 02:53:15 +000011target datalayout = "E-p:32:32:128-f64:64:128-f32:32:128-i64:32:128-i32:32:128-i16:16:128-i8:8:128-i1:8:128-a0:0:128-v128:128:128-s0:128:128"
12target triple = "spu"
Scott Michel0a92af42007-12-19 20:50:49 +000013
14define float @fp_add(float %arg1, float %arg2) {
Dan Gohmanae3a0be2009-06-04 22:49:04 +000015 %A = fadd float %arg1, %arg2 ; <float> [#uses=1]
Scott Michel53dec472008-03-05 23:00:19 +000016 ret float %A
Scott Michel0a92af42007-12-19 20:50:49 +000017}
18
19define <4 x float> @fp_add_vec(<4 x float> %arg1, <4 x float> %arg2) {
Dan Gohmanae3a0be2009-06-04 22:49:04 +000020 %A = fadd <4 x float> %arg1, %arg2 ; <<4 x float>> [#uses=1]
Scott Michel53dec472008-03-05 23:00:19 +000021 ret <4 x float> %A
Scott Michel0a92af42007-12-19 20:50:49 +000022}
23
24define float @fp_sub(float %arg1, float %arg2) {
Dan Gohmanae3a0be2009-06-04 22:49:04 +000025 %A = fsub float %arg1, %arg2 ; <float> [#uses=1]
Scott Michel53dec472008-03-05 23:00:19 +000026 ret float %A
Scott Michel0a92af42007-12-19 20:50:49 +000027}
28
29define <4 x float> @fp_sub_vec(<4 x float> %arg1, <4 x float> %arg2) {
Dan Gohmanae3a0be2009-06-04 22:49:04 +000030 %A = fsub <4 x float> %arg1, %arg2 ; <<4 x float>> [#uses=1]
Scott Michel53dec472008-03-05 23:00:19 +000031 ret <4 x float> %A
Scott Michel0a92af42007-12-19 20:50:49 +000032}
33
34define float @fp_mul(float %arg1, float %arg2) {
Dan Gohmanae3a0be2009-06-04 22:49:04 +000035 %A = fmul float %arg1, %arg2 ; <float> [#uses=1]
Scott Michel53dec472008-03-05 23:00:19 +000036 ret float %A
Scott Michel0a92af42007-12-19 20:50:49 +000037}
38
39define <4 x float> @fp_mul_vec(<4 x float> %arg1, <4 x float> %arg2) {
Dan Gohmanae3a0be2009-06-04 22:49:04 +000040 %A = fmul <4 x float> %arg1, %arg2 ; <<4 x float>> [#uses=1]
Scott Michel53dec472008-03-05 23:00:19 +000041 ret <4 x float> %A
Scott Michel0a92af42007-12-19 20:50:49 +000042}
43
44define float @fp_mul_add(float %arg1, float %arg2, float %arg3) {
Dan Gohmanae3a0be2009-06-04 22:49:04 +000045 %A = fmul float %arg1, %arg2 ; <float> [#uses=1]
46 %B = fadd float %A, %arg3 ; <float> [#uses=1]
Scott Michel53dec472008-03-05 23:00:19 +000047 ret float %B
Scott Michel0a92af42007-12-19 20:50:49 +000048}
49
50define <4 x float> @fp_mul_add_vec(<4 x float> %arg1, <4 x float> %arg2, <4 x float> %arg3) {
Dan Gohmanae3a0be2009-06-04 22:49:04 +000051 %A = fmul <4 x float> %arg1, %arg2 ; <<4 x float>> [#uses=1]
52 %B = fadd <4 x float> %A, %arg3 ; <<4 x float>> [#uses=1]
Scott Michel53dec472008-03-05 23:00:19 +000053 ret <4 x float> %B
Scott Michel0a92af42007-12-19 20:50:49 +000054}
55
56define float @fp_mul_sub(float %arg1, float %arg2, float %arg3) {
Dan Gohmanae3a0be2009-06-04 22:49:04 +000057 %A = fmul float %arg1, %arg2 ; <float> [#uses=1]
58 %B = fsub float %A, %arg3 ; <float> [#uses=1]
Scott Michel53dec472008-03-05 23:00:19 +000059 ret float %B
Scott Michel0a92af42007-12-19 20:50:49 +000060}
61
62define <4 x float> @fp_mul_sub_vec(<4 x float> %arg1, <4 x float> %arg2, <4 x float> %arg3) {
Dan Gohmanae3a0be2009-06-04 22:49:04 +000063 %A = fmul <4 x float> %arg1, %arg2 ; <<4 x float>> [#uses=1]
64 %B = fsub <4 x float> %A, %arg3 ; <<4 x float>> [#uses=1]
Scott Michel53dec472008-03-05 23:00:19 +000065 ret <4 x float> %B
Scott Michel0a92af42007-12-19 20:50:49 +000066}
67
68; Test the straightforward way of getting fnms
69; c - a * b
70define float @fp_neg_mul_sub_1(float %arg1, float %arg2, float %arg3) {
Dan Gohmanae3a0be2009-06-04 22:49:04 +000071 %A = fmul float %arg1, %arg2
72 %B = fsub float %arg3, %A
Scott Michel53dec472008-03-05 23:00:19 +000073 ret float %B
Scott Michel0a92af42007-12-19 20:50:49 +000074}
75
76; Test another way of getting fnms
77; - ( a *b -c ) = c - a * b
78define float @fp_neg_mul_sub_2(float %arg1, float %arg2, float %arg3) {
Dan Gohmanae3a0be2009-06-04 22:49:04 +000079 %A = fmul float %arg1, %arg2
80 %B = fsub float %A, %arg3
81 %C = fsub float -0.0, %B
Scott Michel53dec472008-03-05 23:00:19 +000082 ret float %C
Scott Michel0a92af42007-12-19 20:50:49 +000083}
84
85define <4 x float> @fp_neg_mul_sub_vec(<4 x float> %arg1, <4 x float> %arg2, <4 x float> %arg3) {
Dan Gohmanae3a0be2009-06-04 22:49:04 +000086 %A = fmul <4 x float> %arg1, %arg2
87 %B = fsub <4 x float> %A, %arg3
88 %D = fsub <4 x float> < float -0.0, float -0.0, float -0.0, float -0.0 >, %B
Scott Michel53dec472008-03-05 23:00:19 +000089 ret <4 x float> %D
Scott Michel0a92af42007-12-19 20:50:49 +000090}