1; RUN: opt < %s -instcombine -S | FileCheck %s 2 3define double @pow_intrinsic_half_fast(double %x) { 4; CHECK-LABEL: @pow_intrinsic_half_fast( 5; CHECK-NEXT: [[TMP1:%.*]] = call fast double @llvm.sqrt.f64(double %x) 6; CHECK-NEXT: ret double [[TMP1]] 7; 8 %pow = call fast double @llvm.pow.f64(double %x, double 5.000000e-01) 9 ret double %pow 10} 11 12define <2 x double> @pow_intrinsic_half_approx(<2 x double> %x) { 13; CHECK-LABEL: @pow_intrinsic_half_approx( 14; CHECK-NEXT: [[POW:%.*]] = call afn <2 x double> @llvm.pow.v2f64(<2 x double> %x, <2 x double> <double 5.000000e-01, double 5.000000e-01>) 15; CHECK-NEXT: ret <2 x double> [[POW]] 16; 17 %pow = call afn <2 x double> @llvm.pow.v2f64(<2 x double> %x, <2 x double> <double 5.0e-01, double 5.0e-01>) 18 ret <2 x double> %pow 19} 20 21define double @pow_libcall_half_approx(double %x) { 22; CHECK-LABEL: @pow_libcall_half_approx( 23; CHECK-NEXT: [[SQRT:%.*]] = call afn double @sqrt(double %x) 24; CHECK-NEXT: [[TMP1:%.*]] = call afn double @llvm.fabs.f64(double [[SQRT]]) 25; CHECK-NEXT: [[TMP2:%.*]] = fcmp afn oeq double %x, 0xFFF0000000000000 26; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP2]], double 0x7FF0000000000000, double [[TMP1]] 27; CHECK-NEXT: ret double [[TMP3]] 28; 29 %pow = call afn double @pow(double %x, double 5.0e-01) 30 ret double %pow 31} 32 33define <2 x double> @pow_intrinsic_neghalf_fast(<2 x double> %x) { 34; CHECK-LABEL: @pow_intrinsic_neghalf_fast( 35; CHECK-NEXT: [[TMP1:%.*]] = call fast <2 x double> @llvm.sqrt.v2f64(<2 x double> %x) 36; CHECK-NEXT: [[TMP2:%.*]] = fdiv fast <2 x double> <double 1.000000e+00, double 1.000000e+00>, [[TMP1]] 37; CHECK-NEXT: ret <2 x double> [[TMP2]] 38; 39 %pow = call fast <2 x double> @llvm.pow.v2f64(<2 x double> %x, <2 x double> <double -5.0e-01, double -5.0e-01>) 40 ret <2 x double> %pow 41} 42 43define double @pow_intrinsic_neghalf_approx(double %x) { 44; CHECK-LABEL: @pow_intrinsic_neghalf_approx( 45; CHECK-NEXT: [[POW:%.*]] = call afn double @llvm.pow.f64(double %x, double -5.000000e-01) 46; CHECK-NEXT: ret double [[POW]] 47; 48 %pow = call afn double @llvm.pow.f64(double %x, double -5.0e-01) 49 ret double %pow 50} 51 52define float @pow_libcall_neghalf_fast(float %x) { 53; CHECK-LABEL: @pow_libcall_neghalf_fast( 54; CHECK-NEXT: [[SQRTF:%.*]] = call fast float @sqrtf(float %x) 55; CHECK-NEXT: [[TMP1:%.*]] = fdiv fast float 1.000000e+00, [[SQRTF]] 56; CHECK-NEXT: ret float [[TMP1]] 57; 58 %pow = call fast float @powf(float %x, float -5.0e-01) 59 ret float %pow 60} 61 62declare double @llvm.pow.f64(double, double) #0 63declare <2 x double> @llvm.pow.v2f64(<2 x double>, <2 x double>) #0 64declare double @pow(double, double) 65declare float @powf(float, float) 66 67attributes #0 = { nounwind readnone speculatable } 68attributes #1 = { nounwind readnone } 69 70