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