1 ; RUN: opt < %s -instcombine -S | FileCheck %s
3 declare <4 x float> @llvm.x86.vcvtph2ps.128(<8 x i16>)
4 declare <8 x float> @llvm.x86.vcvtph2ps.256(<8 x i16>)
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)
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)
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>)
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>)
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>)
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>)