1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
4 declare <4 x float> @llvm.x86.vcvtph2ps.128(<8 x i16>)
5 declare <8 x float> @llvm.x86.vcvtph2ps.256(<8 x i16>)
11 ; Only bottom 4 elements required.
12 define <4 x float> @demand_vcvtph2ps_128(<8 x i16> %A) {
13 ; CHECK-LABEL: @demand_vcvtph2ps_128(
14 ; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <8 x i16> [[A:%.*]], <8 x i16> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
15 ; CHECK-NEXT: [[TMP2:%.*]] = bitcast <4 x i16> [[TMP1]] to <4 x half>
16 ; CHECK-NEXT: [[CVTPH2PS:%.*]] = fpext <4 x half> [[TMP2]] to <4 x float>
17 ; CHECK-NEXT: ret <4 x float> [[CVTPH2PS]]
19 %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>
20 %2 = tail call <4 x float> @llvm.x86.vcvtph2ps.128(<8 x i16> %1)
24 ; All 8 elements required.
25 define <8 x float> @demand_vcvtph2ps_256(<8 x i16> %A) {
26 ; CHECK-LABEL: @demand_vcvtph2ps_256(
27 ; CHECK-NEXT: [[TMP1:%.*]] = bitcast <8 x i16> [[A:%.*]] to <8 x half>
28 ; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <8 x half> [[TMP1]], <8 x half> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3>
29 ; CHECK-NEXT: [[CVTPH2PS:%.*]] = fpext <8 x half> [[TMP2]] to <8 x float>
30 ; CHECK-NEXT: ret <8 x float> [[CVTPH2PS]]
32 %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>
33 %2 = tail call <8 x float> @llvm.x86.vcvtph2ps.256(<8 x i16> %1)
41 define <4 x float> @fold_vcvtph2ps_128() {
42 ; CHECK-LABEL: @fold_vcvtph2ps_128(
43 ; CHECK-NEXT: ret <4 x float> <float 0.000000e+00, float 5.000000e-01, float 1.000000e+00, float -0.000000e+00>
45 %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>)
49 define <8 x float> @fold_vcvtph2ps_256() {
50 ; CHECK-LABEL: @fold_vcvtph2ps_256(
51 ; 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>
53 %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>)
57 define <4 x float> @fold_vcvtph2ps_128_zero() {
58 ; CHECK-LABEL: @fold_vcvtph2ps_128_zero(
59 ; CHECK-NEXT: ret <4 x float> zeroinitializer
61 %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>)
65 define <8 x float> @fold_vcvtph2ps_256_zero() {
66 ; CHECK-LABEL: @fold_vcvtph2ps_256_zero(
67 ; CHECK-NEXT: ret <8 x float> zeroinitializer
69 %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>)