1; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr7 -enable-unsafe-fp-math | FileCheck %s 2; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr7 | FileCheck -check-prefix=CHECK-SAFE %s 3target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v128:128:128-n32:64" 4target triple = "powerpc64-unknown-linux-gnu" 5 6declare double @llvm.sqrt.f64(double) 7declare float @llvm.sqrt.f32(float) 8declare <4 x float> @llvm.sqrt.v4f32(<4 x float>) 9 10define double @foo(double %a, double %b) nounwind { 11entry: 12 %x = call double @llvm.sqrt.f64(double %b) 13 %r = fdiv double %a, %x 14 ret double %r 15 16; CHECK: @foo 17; CHECK-DAG: frsqrte 18; CHECK-DAG: fnmsub 19; CHECK: fmul 20; CHECK: fmadd 21; CHECK: fmul 22; CHECK: fmul 23; CHECK: fmadd 24; CHECK: fmul 25; CHECK: fmul 26; CHECK: blr 27 28; CHECK-SAFE: @foo 29; CHECK-SAFE: fsqrt 30; CHECK-SAFE: fdiv 31; CHECK-SAFE: blr 32} 33 34define double @foof(double %a, float %b) nounwind { 35entry: 36 %x = call float @llvm.sqrt.f32(float %b) 37 %y = fpext float %x to double 38 %r = fdiv double %a, %y 39 ret double %r 40 41; CHECK: @foof 42; CHECK-DAG: frsqrtes 43; CHECK-DAG: fnmsubs 44; CHECK: fmuls 45; CHECK: fmadds 46; CHECK: fmuls 47; CHECK: fmul 48; CHECK: blr 49 50; CHECK-SAFE: @foof 51; CHECK-SAFE: fsqrts 52; CHECK-SAFE: fdiv 53; CHECK-SAFE: blr 54} 55 56define float @food(float %a, double %b) nounwind { 57entry: 58 %x = call double @llvm.sqrt.f64(double %b) 59 %y = fptrunc double %x to float 60 %r = fdiv float %a, %y 61 ret float %r 62 63; CHECK: @foo 64; CHECK-DAG: frsqrte 65; CHECK-DAG: fnmsub 66; CHECK: fmul 67; CHECK: fmadd 68; CHECK: fmul 69; CHECK: fmul 70; CHECK: fmadd 71; CHECK: fmul 72; CHECK: frsp 73; CHECK: fmuls 74; CHECK: blr 75 76; CHECK-SAFE: @foo 77; CHECK-SAFE: fsqrt 78; CHECK-SAFE: fdivs 79; CHECK-SAFE: blr 80} 81 82define float @goo(float %a, float %b) nounwind { 83entry: 84 %x = call float @llvm.sqrt.f32(float %b) 85 %r = fdiv float %a, %x 86 ret float %r 87 88; CHECK: @goo 89; CHECK-DAG: frsqrtes 90; CHECK-DAG: fnmsubs 91; CHECK: fmuls 92; CHECK: fmadds 93; CHECK: fmuls 94; CHECK: fmuls 95; CHECK: blr 96 97; CHECK-SAFE: @goo 98; CHECK-SAFE: fsqrts 99; CHECK-SAFE: fdivs 100; CHECK-SAFE: blr 101} 102 103define <4 x float> @hoo(<4 x float> %a, <4 x float> %b) nounwind { 104entry: 105 %x = call <4 x float> @llvm.sqrt.v4f32(<4 x float> %b) 106 %r = fdiv <4 x float> %a, %x 107 ret <4 x float> %r 108 109; CHECK: @hoo 110; CHECK: vrsqrtefp 111 112; CHECK-SAFE: @hoo 113; CHECK-SAFE-NOT: vrsqrtefp 114; CHECK-SAFE: blr 115} 116 117define double @foo2(double %a, double %b) nounwind { 118entry: 119 %r = fdiv double %a, %b 120 ret double %r 121 122; CHECK: @foo2 123; CHECK-DAG: fre 124; CHECK-DAG: fnmsub 125; CHECK: fmadd 126; CHECK: fnmsub 127; CHECK: fmadd 128; CHECK: fmul 129; CHECK: blr 130 131; CHECK-SAFE: @foo2 132; CHECK-SAFE: fdiv 133; CHECK-SAFE: blr 134} 135 136define float @goo2(float %a, float %b) nounwind { 137entry: 138 %r = fdiv float %a, %b 139 ret float %r 140 141; CHECK: @goo2 142; CHECK-DAG: fres 143; CHECK-DAG: fnmsubs 144; CHECK: fmadds 145; CHECK: fmuls 146; CHECK: blr 147 148; CHECK-SAFE: @goo2 149; CHECK-SAFE: fdivs 150; CHECK-SAFE: blr 151} 152 153define <4 x float> @hoo2(<4 x float> %a, <4 x float> %b) nounwind { 154entry: 155 %r = fdiv <4 x float> %a, %b 156 ret <4 x float> %r 157 158; CHECK: @hoo2 159; CHECK: vrefp 160 161; CHECK-SAFE: @hoo2 162; CHECK-SAFE-NOT: vrefp 163; CHECK-SAFE: blr 164} 165 166define double @foo3(double %a) nounwind { 167entry: 168 %r = call double @llvm.sqrt.f64(double %a) 169 ret double %r 170 171; CHECK: @foo3 172; CHECK: fcmpu 173; CHECK-DAG: frsqrte 174; CHECK-DAG: fnmsub 175; CHECK: fmul 176; CHECK: fmadd 177; CHECK: fmul 178; CHECK: fmul 179; CHECK: fmadd 180; CHECK: fmul 181; CHECK: fre 182; CHECK: fnmsub 183; CHECK: fmadd 184; CHECK: fnmsub 185; CHECK: fmadd 186; CHECK: blr 187 188; CHECK-SAFE: @foo3 189; CHECK-SAFE: fsqrt 190; CHECK-SAFE: blr 191} 192 193define float @goo3(float %a) nounwind { 194entry: 195 %r = call float @llvm.sqrt.f32(float %a) 196 ret float %r 197 198; CHECK: @goo3 199; CHECK: fcmpu 200; CHECK-DAG: frsqrtes 201; CHECK-DAG: fnmsubs 202; CHECK: fmuls 203; CHECK: fmadds 204; CHECK: fmuls 205; CHECK: fres 206; CHECK: fnmsubs 207; CHECK: fmadds 208; CHECK: blr 209 210; CHECK-SAFE: @goo3 211; CHECK-SAFE: fsqrts 212; CHECK-SAFE: blr 213} 214 215define <4 x float> @hoo3(<4 x float> %a) nounwind { 216entry: 217 %r = call <4 x float> @llvm.sqrt.v4f32(<4 x float> %a) 218 ret <4 x float> %r 219 220; CHECK: @hoo3 221; CHECK: vrsqrtefp 222; CHECK-DAG: vrefp 223; CHECK-DAG: vcmpeqfp 224 225; CHECK-SAFE: @hoo3 226; CHECK-SAFE-NOT: vrsqrtefp 227; CHECK-SAFE: blr 228} 229 230