1 ; RUN: opt < %s -instcombine -S | FileCheck %s 2 3 declare <4 x float> @llvm.x86.vcvtph2ps.128(<8 x i16>) 4 declare <8 x float> @llvm.x86.vcvtph2ps.256(<8 x i16>) 5 6 ; 7 ; Vector Demanded Bits 8 ; 9 10 ; Only bottom 4 elements required. 11 define <4 x float> @demand_vcvtph2ps_128(<8 x i16> %A) { 12 ; CHECK-LABEL: @demand_vcvtph2ps_128 13 ; CHECK-NEXT: %1 = tail call <4 x float> @llvm.x86.vcvtph2ps.128(<8 x i16> %A) 14 ; CHECK-NEXT: ret <4 x float> %1 15 %1 = shufflevector <8 x i16> %A, <8 x i16> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3> 16 %2 = tail call <4 x float> @llvm.x86.vcvtph2ps.128(<8 x i16> %1) 17 ret <4 x float> %2 18 } 19 20 ; All 8 elements required. 21 define <8 x float> @demand_vcvtph2ps_256(<8 x i16> %A) { 22 ; CHECK-LABEL: @demand_vcvtph2ps_256 23 ; CHECK-NEXT: %1 = shufflevector <8 x i16> %A, <8 x i16> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3> 24 ; CHECK-NEXT: %2 = tail call <8 x float> @llvm.x86.vcvtph2ps.256(<8 x i16> %1) 25 ; CHECK-NEXT: ret <8 x float> %2 26 %1 = shufflevector <8 x i16> %A, <8 x i16> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3> 27 %2 = tail call <8 x float> @llvm.x86.vcvtph2ps.256(<8 x i16> %1) 28 ret <8 x float> %2 29 } 30 31 ; 32 ; Constant Folding 33 ; 34 35 define <4 x float> @fold_vcvtph2ps_128() { 36 ; CHECK-LABEL: @fold_vcvtph2ps_128 37 ; CHECK-NEXT: ret <4 x float> <float 0.000000e+00, float 5.000000e-01, float 1.000000e+00, float -0.000000e+00> 38 %1 = tail call <4 x float> @llvm.x86.vcvtph2ps.128(<8 x i16> <i16 0, i16 14336, i16 15360, i16 32768, i16 16384, i16 31743, i16 48128, i16 49152>) 39 ret <4 x float> %1 40 } 41 42 define <8 x float> @fold_vcvtph2ps_256() { 43 ; CHECK-LABEL: @fold_vcvtph2ps_256 44 ; CHECK-NEXT: ret <8 x float> <float 0.000000e+00, float 5.000000e-01, float 1.000000e+00, float -0.000000e+00, float 2.000000e+00, float 6.550400e+04, float -1.000000e+00, float -2.000000e+00> 45 %1 = tail call <8 x float> @llvm.x86.vcvtph2ps.256(<8 x i16> <i16 0, i16 14336, i16 15360, i16 32768, i16 16384, i16 31743, i16 48128, i16 49152>) 46 ret <8 x float> %1 47 } 48 49 define <4 x float> @fold_vcvtph2ps_128_zero() { 50 ; CHECK-LABEL: @fold_vcvtph2ps_128_zero 51 ; CHECK-NEXT: ret <4 x float> zeroinitializer 52 %1 = tail call <4 x float> @llvm.x86.vcvtph2ps.128(<8 x i16> <i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0>) 53 ret <4 x float> %1 54 } 55 56 define <8 x float> @fold_vcvtph2ps_256_zero() { 57 ; CHECK-LABEL: @fold_vcvtph2ps_256_zero 58 ; CHECK-NEXT: ret <8 x float> zeroinitializer 59 %1 = tail call <8 x float> @llvm.x86.vcvtph2ps.256(<8 x i16> <i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0>) 60 ret <8 x float> %1 61 } 62