1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -instcombine -S | FileCheck %s 3 4declare double @llvm.cos.f64(double %Val) 5declare float @llvm.cos.f32(float %Val) 6declare <2 x float> @llvm.cos.v2f32(<2 x float> %Val) 7 8declare float @llvm.fabs.f32(float %Val) 9declare <2 x float> @llvm.fabs.v2f32(<2 x float> %Val) 10 11define double @undef_arg() { 12; CHECK-LABEL: @undef_arg( 13; CHECK-NEXT: ret double 0.000000e+00 14; 15 %r = call double @llvm.cos.f64(double undef) 16 ret double %r 17} 18 19define float @undef_arg2(float %d) { 20; CHECK-LABEL: @undef_arg2( 21; CHECK-NEXT: [[COSVAL:%.*]] = call float @llvm.cos.f32(float [[D:%.*]]) 22; CHECK-NEXT: [[FSUM:%.*]] = fadd float [[COSVAL]], 0.000000e+00 23; CHECK-NEXT: ret float [[FSUM]] 24; 25 %cosval = call float @llvm.cos.f32(float %d) 26 %cosval2 = call float @llvm.cos.f32(float undef) 27 %fsum = fadd float %cosval2, %cosval 28 ret float %fsum 29} 30 31define float @fneg_f32(float %x) { 32; CHECK-LABEL: @fneg_f32( 33; CHECK-NEXT: [[COS:%.*]] = call float @llvm.cos.f32(float [[X:%.*]]) 34; CHECK-NEXT: ret float [[COS]] 35; 36 %x.fneg = fsub float -0.0, %x 37 %cos = call float @llvm.cos.f32(float %x.fneg) 38 ret float %cos 39} 40 41define <2 x float> @fneg_v2f32(<2 x float> %x) { 42; CHECK-LABEL: @fneg_v2f32( 43; CHECK-NEXT: [[COS:%.*]] = call <2 x float> @llvm.cos.v2f32(<2 x float> [[X:%.*]]) 44; CHECK-NEXT: ret <2 x float> [[COS]] 45; 46 %x.fneg = fsub <2 x float> <float -0.0, float -0.0>, %x 47 %cos = call <2 x float> @llvm.cos.v2f32(<2 x float> %x.fneg) 48 ret <2 x float> %cos 49} 50 51define float @fabs_f32(float %x) { 52; CHECK-LABEL: @fabs_f32( 53; CHECK-NEXT: [[COS:%.*]] = call float @llvm.cos.f32(float [[X:%.*]]) 54; CHECK-NEXT: ret float [[COS]] 55; 56 %x.fabs = call float @llvm.fabs.f32(float %x) 57 %cos = call float @llvm.cos.f32(float %x.fabs) 58 ret float %cos 59} 60 61define float @fabs_fneg_f32(float %x) { 62; CHECK-LABEL: @fabs_fneg_f32( 63; CHECK-NEXT: [[COS:%.*]] = call float @llvm.cos.f32(float [[X:%.*]]) 64; CHECK-NEXT: ret float [[COS]] 65; 66 %x.fabs = call float @llvm.fabs.f32(float %x) 67 %x.fabs.fneg = fsub float -0.0, %x.fabs 68 %cos = call float @llvm.cos.f32(float %x.fabs.fneg) 69 ret float %cos 70} 71 72define <2 x float> @fabs_fneg_v2f32(<2 x float> %x) { 73; CHECK-LABEL: @fabs_fneg_v2f32( 74; CHECK-NEXT: [[COS:%.*]] = call <2 x float> @llvm.cos.v2f32(<2 x float> [[X:%.*]]) 75; CHECK-NEXT: ret <2 x float> [[COS]] 76; 77 %x.fabs = call <2 x float> @llvm.fabs.v2f32(<2 x float> %x) 78 %x.fabs.fneg = fsub <2 x float> <float -0.0, float -0.0>, %x.fabs 79 %cos = call <2 x float> @llvm.cos.v2f32(<2 x float> %x.fabs.fneg) 80 ret <2 x float> %cos 81} 82 83