1 ; RUN: opt -S -scalarizer %s | FileCheck %s
2 ; RUN: opt -S -passes='function(scalarizer)' %s | FileCheck %s
5 declare <2 x float> @llvm.sqrt.v2f32(<2 x float>)
8 declare <2 x float> @llvm.minnum.v2f32(<2 x float>, <2 x float>)
9 declare <2 x float> @llvm.minimum.v2f32(<2 x float>, <2 x float>)
10 declare <2 x float> @llvm.maximum.v2f32(<2 x float>, <2 x float>)
13 declare <2 x float> @llvm.fma.v2f32(<2 x float>, <2 x float>, <2 x float>)
16 declare <2 x i32> @llvm.bswap.v2i32(<2 x i32>)
18 ; Unary int plus constant scalar operand
19 declare <2 x i32> @llvm.ctlz.v2i32(<2 x i32>, i1)
21 ; Unary fp plus any scalar operand
22 declare <2 x float> @llvm.powi.v2f32(<2 x float>, i32)
24 ; Binary int plus constant scalar operand
25 declare <2 x i32> @llvm.smul.fix.sat.v2i32(<2 x i32>, <2 x i32>, i32)
28 ; CHECK-LABEL: @scalarize_sqrt_v2f32(
29 ; CHECK: %sqrt.i0 = call float @llvm.sqrt.f32(float %x.i0)
30 ; CHECK: %sqrt.i1 = call float @llvm.sqrt.f32(float %x.i1)
31 ; CHECK: %sqrt.upto0 = insertelement <2 x float> undef, float %sqrt.i0, i32 0
32 ; CHECK: %sqrt = insertelement <2 x float> %sqrt.upto0, float %sqrt.i1, i32 1
33 ; CHECK: ret <2 x float> %sqrt
34 define <2 x float> @scalarize_sqrt_v2f32(<2 x float> %x) #0 {
35 %sqrt = call <2 x float> @llvm.sqrt.v2f32(<2 x float> %x)
39 ; CHECK-LABEL: @scalarize_minnum_v2f32(
40 ; CHECK: %minnum.i0 = call float @llvm.minnum.f32(float %x.i0, float %y.i0)
41 ; CHECK: %minnum.i1 = call float @llvm.minnum.f32(float %x.i1, float %y.i1)
42 ; CHECK: %minnum.upto0 = insertelement <2 x float> undef, float %minnum.i0, i32 0
43 ; CHECK: %minnum = insertelement <2 x float> %minnum.upto0, float %minnum.i1, i32 1
44 ; CHECK: ret <2 x float> %minnum
45 define <2 x float> @scalarize_minnum_v2f32(<2 x float> %x, <2 x float> %y) #0 {
46 %minnum = call <2 x float> @llvm.minnum.v2f32(<2 x float> %x, <2 x float> %y)
47 ret <2 x float> %minnum
50 ; CHECK-LABEL: @scalarize_minimum_v2f32(
51 ; CHECK: %minimum.i0 = call float @llvm.minimum.f32(float %x.i0, float %y.i0)
52 ; CHECK: %minimum.i1 = call float @llvm.minimum.f32(float %x.i1, float %y.i1)
53 ; CHECK: %minimum.upto0 = insertelement <2 x float> undef, float %minimum.i0, i32 0
54 ; CHECK: %minimum = insertelement <2 x float> %minimum.upto0, float %minimum.i1, i32 1
55 ; CHECK: ret <2 x float> %minimum
56 define <2 x float> @scalarize_minimum_v2f32(<2 x float> %x, <2 x float> %y) #0 {
57 %minimum = call <2 x float> @llvm.minimum.v2f32(<2 x float> %x, <2 x float> %y)
58 ret <2 x float> %minimum
61 ; CHECK-LABEL: @scalarize_maximum_v2f32(
62 ; CHECK: %maximum.i0 = call float @llvm.maximum.f32(float %x.i0, float %y.i0)
63 ; CHECK: %maximum.i1 = call float @llvm.maximum.f32(float %x.i1, float %y.i1)
64 ; CHECK: %maximum.upto0 = insertelement <2 x float> undef, float %maximum.i0, i32 0
65 ; CHECK: %maximum = insertelement <2 x float> %maximum.upto0, float %maximum.i1, i32 1
66 ; CHECK: ret <2 x float> %maximum
67 define <2 x float> @scalarize_maximum_v2f32(<2 x float> %x, <2 x float> %y) #0 {
68 %maximum = call <2 x float> @llvm.maximum.v2f32(<2 x float> %x, <2 x float> %y)
69 ret <2 x float> %maximum
72 ; CHECK-LABEL: @scalarize_fma_v2f32(
73 ; CHECK: %fma.i0 = call float @llvm.fma.f32(float %x.i0, float %y.i0, float %z.i0)
74 ; CHECK: %fma.i1 = call float @llvm.fma.f32(float %x.i1, float %y.i1, float %z.i1)
75 ; CHECK: %fma.upto0 = insertelement <2 x float> undef, float %fma.i0, i32 0
76 ; CHECK: %fma = insertelement <2 x float> %fma.upto0, float %fma.i1, i32 1
77 ; CHECK: ret <2 x float> %fma
78 define <2 x float> @scalarize_fma_v2f32(<2 x float> %x, <2 x float> %y, <2 x float> %z) #0 {
79 %fma = call <2 x float> @llvm.fma.v2f32(<2 x float> %x, <2 x float> %y, <2 x float> %z)
83 ; CHECK-LABEL: @scalarize_bswap_v2i32(
84 ; CHECK: %bswap.i0 = call i32 @llvm.bswap.i32(i32 %x.i0)
85 ; CHECK: %bswap.i1 = call i32 @llvm.bswap.i32(i32 %x.i1)
86 ; CHECK: %bswap.upto0 = insertelement <2 x i32> undef, i32 %bswap.i0, i32 0
87 ; CHECK: %bswap = insertelement <2 x i32> %bswap.upto0, i32 %bswap.i1, i32 1
88 ; CHECK: ret <2 x i32> %bswap
89 define <2 x i32> @scalarize_bswap_v2i32(<2 x i32> %x) #0 {
90 %bswap = call <2 x i32> @llvm.bswap.v2i32(<2 x i32> %x)
94 ; CHECK-LABEL: @scalarize_ctlz_v2i32(
95 ; CHECK: %ctlz.i0 = call i32 @llvm.ctlz.i32(i32 %x.i0, i1 true)
96 ; CHECK: %ctlz.i1 = call i32 @llvm.ctlz.i32(i32 %x.i1, i1 true)
97 ; CHECK: %ctlz.upto0 = insertelement <2 x i32> undef, i32 %ctlz.i0, i32 0
98 ; CHECK: %ctlz = insertelement <2 x i32> %ctlz.upto0, i32 %ctlz.i1, i32 1
99 ; CHECK: ret <2 x i32> %ctlz
100 define <2 x i32> @scalarize_ctlz_v2i32(<2 x i32> %x) #0 {
101 %ctlz = call <2 x i32> @llvm.ctlz.v2i32(<2 x i32> %x, i1 true)
105 ; CHECK-LABEL: @scalarize_powi_v2f32(
106 ; CHECK: %powi.i0 = call float @llvm.powi.f32(float %x.i0, i32 %y)
107 ; CHECK: %powi.i1 = call float @llvm.powi.f32(float %x.i1, i32 %y)
108 ; CHECK: %powi.upto0 = insertelement <2 x float> undef, float %powi.i0, i32 0
109 ; CHECK: %powi = insertelement <2 x float> %powi.upto0, float %powi.i1, i32 1
110 ; CHECK: ret <2 x float> %powi
111 define <2 x float> @scalarize_powi_v2f32(<2 x float> %x, i32 %y) #0 {
112 %powi = call <2 x float> @llvm.powi.v2f32(<2 x float> %x, i32 %y)
113 ret <2 x float> %powi
116 ; CHECK-LABEL: @scalarize_smul_fix_sat_v2i32(
117 ; CHECK: %smulfixsat.i0 = call i32 @llvm.smul.fix.sat.i32(i32 %x.i0, i32 5, i32 31)
118 ; CHECK: %smulfixsat.i1 = call i32 @llvm.smul.fix.sat.i32(i32 %x.i1, i32 19, i32 31)
119 ; CHECK: %smulfixsat.upto0 = insertelement <2 x i32> undef, i32 %smulfixsat.i0, i32 0
120 ; CHECK: %smulfixsat = insertelement <2 x i32> %smulfixsat.upto0, i32 %smulfixsat.i1, i32 1
121 ; CHECK: ret <2 x i32> %smulfixsat
122 define <2 x i32> @scalarize_smul_fix_sat_v2i32(<2 x i32> %x) #0 {
123 %smulfixsat = call <2 x i32> @llvm.smul.fix.sat.v2i32(<2 x i32> %x, <2 x i32> <i32 5, i32 19>, i32 31)
124 ret <2 x i32> %smulfixsat