1 ; RUN: llc -march=sparc < %s | FileCheck %s -check-prefix=V8 2 ; RUN: llc -march=sparc -O0 < %s | FileCheck %s -check-prefix=V8-UNOPT 3 ; RUN: llc -march=sparc -mattr=v9 < %s | FileCheck %s -check-prefix=V9 4 ; RUN: llc -mtriple=sparc64-unknown-linux < %s | FileCheck %s -check-prefix=SPARC64 5 6 ; V8-LABEL: test_neg: 7 ; V8: call get_double 8 ; V8: fnegs %f0, %f0 9 10 ; V8-UNOPT-LABEL: test_neg: 11 ; V8-UNOPT: fnegs 12 ; V8-UNOPT: ! implicit-def 13 ; V8-UNOPT: fmovs {{.+}}, %f0 14 ; V8-UNOPT: fmovs {{.+}}, %f1 15 16 ; V9-LABEL: test_neg: 17 ; V9: fnegd %f0, %f0 18 19 ; SPARC64-LABEL: test_neg: 20 ; SPARC64: fnegd %f0, %f0 21 22 define double @test_neg() { 23 entry: 24 %0 = tail call double @get_double() 25 %1 = fsub double -0.000000e+00, %0 26 ret double %1 27 } 28 29 ; V8-LABEL: test_abs: 30 ; V8: fabss %f0, %f0 31 32 ; V8-UNOPT-LABEL: test_abs: 33 ; V8-UNOPT: fabss 34 ; V8-UNOPT: ! implicit-def 35 ; V8-UNOPT: fmovs {{.+}}, %f0 36 ; V8-UNOPT: fmovs {{.+}}, %f1 37 38 ; V9-LABEL: test_abs: 39 ; V9: fabsd %f0, %f0 40 41 42 ; SPARC64-LABEL: test_abs: 43 ; SPARC64: fabsd %f0, %f0 44 45 define double @test_abs() { 46 entry: 47 %0 = tail call double @get_double() 48 %1 = tail call double @llvm.fabs.f64(double %0) 49 ret double %1 50 } 51 52 declare double @get_double() 53 declare double @llvm.fabs.f64(double) nounwind readonly 54 55 ; V8-LABEL: test_v9_floatreg: 56 ; V8: fsubd {{.+}}, {{.+}}, [[R:%f(((1|2)?(0|2|4|6|8))|30)]] 57 ; V8: std [[R]], [%{{.+}}] 58 ; V8: ldd [%{{.+}}], %f0 59 ; V8: faddd {{.+}}, {{.+}}, {{.+}} 60 61 ; V9-LABEL: test_v9_floatreg: 62 ; V9: fsubd {{.+}}, {{.+}}, {{.+}} 63 ; V9: faddd {{.+}}, {{.+}}, %f0 64 65 ; SPARC64-LABEL: test_v9_floatreg: 66 ; SPARC64: fsubd {{.+}}, {{.+}}, {{.+}} 67 ; SPARC64: faddd {{.+}}, {{.+}}, %f0 68 69 define double @test_v9_floatreg() { 70 entry: 71 %0 = tail call double @get_double() 72 %1 = tail call double @get_double() 73 %2 = fsub double %0, %1 74 tail call void asm sideeffect "", "~{f0},~{f2},~{f3},~{f4},~{f5},~{f6},~{f7},~{f8},~{f9},~{f10},~{f11},~{f12},~{f13},~{f14},~{f15},~{f16},~{f17},~{f18},~{f19},~{f20},~{f21},~{f22},~{f23},~{f24},~{f25},~{f26},~{f27},~{f28},~{f29},~{f30},~{f31}"() 75 %3 = fadd double %2, %2 76 ret double %3 77 } 78 79 ; V8-LABEL: test_xtos_stox 80 ; V8: call __floatdisf 81 ; V8: call __fixsfdi 82 83 ; V9-LABEL: test_xtos_stox 84 ; V9: call __floatdisf 85 ; V9: call __fixsfdi 86 87 ; SPARC64-LABEL: test_xtos_stox 88 ; SPARC64: fxtos 89 ; SPARC64: fstox 90 91 define void @test_xtos_stox(i64 %a, i64* %ptr0, float* %ptr1) { 92 entry: 93 %0 = sitofp i64 %a to float 94 store float %0, float* %ptr1, align 8 95 %1 = fptosi float %0 to i64 96 store i64 %1, i64* %ptr0, align 8 97 ret void 98 } 99 100 ; V8-LABEL: test_itos_stoi 101 ; V8: fitos 102 ; V8: fstoi 103 104 ; V9-LABEL: test_itos_stoi 105 ; V9: fitos 106 ; V9: fstoi 107 108 ; SPARC64-LABEL: test_itos_stoi 109 ; SPARC64: fitos 110 ; SPARC64: fstoi 111 112 define void @test_itos_stoi(i32 %a, i32* %ptr0, float* %ptr1) { 113 entry: 114 %0 = sitofp i32 %a to float 115 store float %0, float* %ptr1, align 8 116 %1 = fptosi float %0 to i32 117 store i32 %1, i32* %ptr0, align 8 118 ret void 119 } 120 121 122 ; V8-LABEL: test_xtod_dtox 123 ; V8: call __floatdidf 124 ; V8: call __fixdfdi 125 126 ; V9-LABEL: test_xtod_dtox 127 ; V9: call __floatdidf 128 ; V9: call __fixdfdi 129 130 ; SPARC64-LABEL: test_xtod_dtox 131 ; SPARC64: fxtod 132 ; SPARC64: fdtox 133 134 define void @test_xtod_dtox(i64 %a, i64* %ptr0, double* %ptr1) { 135 entry: 136 %0 = sitofp i64 %a to double 137 store double %0, double* %ptr1, align 8 138 %1 = fptosi double %0 to i64 139 store i64 %1, i64* %ptr0, align 8 140 ret void 141 } 142 143 ; V8-LABEL: test_itod_dtoi 144 ; V8: fitod 145 ; V8: fdtoi 146 147 ; V9-LABEL: test_itod_dtoi 148 ; V9: fitod 149 ; V9: fdtoi 150 151 ; SPARC64-LABEL: test_itod_dtoi 152 ; SPARC64: fitod 153 ; SPARC64: fdtoi 154 155 define void @test_itod_dtoi(i32 %a, double %b, i32* %ptr0, double* %ptr1) { 156 entry: 157 %0 = sitofp i32 %a to double 158 store double %0, double* %ptr1, align 8 159 %1 = fptosi double %b to i32 160 store i32 %1, i32* %ptr0, align 8 161 ret void 162 } 163 164 ; V8-LABEL: test_uxtos_stoux 165 ; V8: call __floatundisf 166 ; V8: call __fixunssfdi 167 168 ; V9-LABEL: test_uxtos_stoux 169 ; V9: call __floatundisf 170 ; V9: call __fixunssfdi 171 172 ; SPARC64-LABEL: test_uxtos_stoux 173 ; SPARC64-NOT: call __floatundisf 174 ; SPARC64-NOT: call __fixunssfdi 175 176 define void @test_uxtos_stoux(i64 %a, i64* %ptr0, float* %ptr1) { 177 entry: 178 %0 = uitofp i64 %a to float 179 store float %0, float* %ptr1, align 8 180 %1 = fptoui float %0 to i64 181 store i64 %1, i64* %ptr0, align 8 182 ret void 183 } 184 185 ; V8-LABEL: test_utos_stou 186 ; V8: fdtos 187 ; V8: fstoi 188 189 ; V9-LABEL: test_utos_stou 190 ; V9: fdtos 191 ; V9: fstoi 192 193 ; SPARC64-LABEL: test_utos_stou 194 ; SPARC64: fdtos 195 ; SPARC64: fstoi 196 197 define void @test_utos_stou(i32 %a, i32* %ptr0, float* %ptr1) { 198 entry: 199 %0 = uitofp i32 %a to float 200 store float %0, float* %ptr1, align 8 201 %1 = fptoui float %0 to i32 202 store i32 %1, i32* %ptr0, align 8 203 ret void 204 } 205 206 207 ; V8-LABEL: test_uxtod_dtoux 208 ; V8: call __floatundidf 209 ; V8: call __fixunsdfdi 210 211 ; V9-LABEL: test_uxtod_dtoux 212 ; V9: call __floatundidf 213 ; V9: call __fixunsdfdi 214 215 ; SPARC64-LABEL: test_uxtod_dtoux 216 ; SPARC64-NOT: call __floatundidf 217 ; SPARC64-NOT: call __floatunsdfdi 218 219 define void @test_uxtod_dtoux(i64 %a, i64* %ptr0, double* %ptr1) { 220 entry: 221 %0 = uitofp i64 %a to double 222 store double %0, double* %ptr1, align 8 223 %1 = fptoui double %0 to i64 224 store i64 %1, i64* %ptr0, align 8 225 ret void 226 } 227 228 ; V8-LABEL: test_utod_dtou 229 ; V8-NOT: fitod 230 ; V8: fdtoi 231 232 ; V9-LABEL: test_utod_dtou 233 ; V9-NOT: fitod 234 ; V9: fdtoi 235 236 ; SPARC64-LABEL: test_utod_dtou 237 ; SPARC64-NOT: fitod 238 ; SPARC64: fdtoi 239 240 define void @test_utod_dtou(i32 %a, double %b, i32* %ptr0, double* %ptr1) { 241 entry: 242 %0 = uitofp i32 %a to double 243 store double %0, double* %ptr1, align 8 244 %1 = fptoui double %b to i32 245 store i32 %1, i32* %ptr0, align 8 246 ret void 247 } 248