1; RUN: llc -march=amdgcn -mcpu=gfx1010 -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN,GFX1010 %s
2
3; GCN-LABEL: {{^}}addMul2D:
4; GFX1010: v_fmac_f16
5; GFX1010: v_fmac_f16
6define hidden <4 x half> @addMul2D(<4 x i8>* nocapture readonly %arg, float addrspace(4)* nocapture readonly %arg1, <2 x i32> %arg2, i32 %arg3) local_unnamed_addr #0 {
7bb:
8  %tmp = extractelement <2 x i32> %arg2, i64 1
9  %tmp4 = icmp sgt i32 %tmp, 0
10  br i1 %tmp4, label %bb5, label %bb36
11
12bb5:                                              ; preds = %bb
13  %tmp6 = extractelement <2 x i32> %arg2, i64 0
14  %tmp7 = icmp sgt i32 %tmp6, 0
15  br label %bb8
16
17bb8:                                              ; preds = %bb32, %bb5
18  %tmp9 = phi <4 x half> [ zeroinitializer, %bb5 ], [ %tmp33, %bb32 ]
19  %tmp10 = phi i32 [ 0, %bb5 ], [ %tmp34, %bb32 ]
20  br i1 %tmp7, label %bb11, label %bb32
21
22bb11:                                             ; preds = %bb8
23  %tmp12 = mul nsw i32 %tmp10, %arg3
24  %tmp13 = mul nsw i32 %tmp10, %tmp6
25  br label %bb14
26
27bb14:                                             ; preds = %bb14, %bb11
28  %tmp15 = phi <4 x half> [ %tmp9, %bb11 ], [ %tmp29, %bb14 ]
29  %tmp16 = phi i32 [ 0, %bb11 ], [ %tmp30, %bb14 ]
30  %tmp17 = add nsw i32 %tmp16, %tmp12
31  %tmp18 = sext i32 %tmp17 to i64
32  %tmp19 = getelementptr inbounds <4 x i8>, <4 x i8>* %arg, i64 %tmp18
33  %tmp20 = load <4 x i8>, <4 x i8>* %tmp19, align 4
34  %tmp21 = tail call <4 x half> @_Z13convert_half4Dv4_h(<4 x i8> %tmp20)
35  %tmp22 = add nsw i32 %tmp16, %tmp13
36  %tmp23 = sext i32 %tmp22 to i64
37  %tmp24 = getelementptr inbounds float, float addrspace(4)* %arg1, i64 %tmp23
38  %tmp25 = load float, float addrspace(4)* %tmp24, align 4
39  %tmp26 = fptrunc float %tmp25 to half
40  %tmp27 = insertelement <4 x half> undef, half %tmp26, i32 0
41  %tmp28 = shufflevector <4 x half> %tmp27, <4 x half> undef, <4 x i32> zeroinitializer
42  %vec.A.0 = extractelement <4 x half> %tmp21, i32 0
43  %vec.B.0 = extractelement <4 x half> %tmp28, i32 0
44  %vec.C.0 = extractelement <4 x half> %tmp15, i32 0
45  %vec.res.0 = tail call half @llvm.fmuladd.f16(half %vec.A.0, half %vec.B.0, half %vec.C.0)
46  %vec.A.1 = extractelement <4 x half> %tmp21, i32 1
47  %vec.B.1 = extractelement <4 x half> %tmp28, i32 1
48  %vec.C.1 = extractelement <4 x half> %tmp15, i32 1
49  %vec.res.1 = tail call half @llvm.fmuladd.f16(half %vec.A.1, half %vec.B.1, half %vec.C.1)
50  %vec.A.2 = extractelement <4 x half> %tmp21, i32 2
51  %vec.B.2 = extractelement <4 x half> %tmp28, i32 2
52  %vec.C.2 = extractelement <4 x half> %tmp15, i32 2
53  %vec.res.2 = tail call half @llvm.fmuladd.f16(half %vec.A.2, half %vec.B.2, half %vec.C.2)
54  %vec.A.3 = extractelement <4 x half> %tmp21, i32 3
55  %vec.B.3 = extractelement <4 x half> %tmp28, i32 3
56  %vec.C.3 = extractelement <4 x half> %tmp15, i32 3
57  %vec.res.3 = tail call half @llvm.fmuladd.f16(half %vec.A.3, half %vec.B.3, half %vec.C.3)
58  %full.res.0 = insertelement <4 x half> undef, half %vec.res.0, i32 0
59  %full.res.1 = insertelement <4 x half> %full.res.0, half %vec.res.1, i32 1
60  %full.res.2 = insertelement <4 x half> %full.res.1, half %vec.res.2, i32 2
61  %tmp29 = insertelement <4 x half> %full.res.2, half %vec.res.3, i32 3
62  %tmp30 = add nuw nsw i32 %tmp16, 1
63  %tmp31 = icmp eq i32 %tmp30, %tmp6
64  br i1 %tmp31, label %bb32, label %bb14
65
66bb32:                                             ; preds = %bb14, %bb8
67  %tmp33 = phi <4 x half> [ %tmp9, %bb8 ], [ %tmp29, %bb14 ]
68  %tmp34 = add nuw nsw i32 %tmp10, 1
69  %tmp35 = icmp eq i32 %tmp34, %tmp
70  br i1 %tmp35, label %bb36, label %bb8
71
72bb36:                                             ; preds = %bb32, %bb
73  %tmp37 = phi <4 x half> [ zeroinitializer, %bb ], [ %tmp33, %bb32 ]
74  ret <4 x half> %tmp37
75}
76
77; Function Attrs: norecurse nounwind readnone
78define linkonce_odr hidden <4 x half> @_Z13convert_half4Dv4_h(<4 x i8> %arg) local_unnamed_addr #1 {
79bb:
80  %tmp = extractelement <4 x i8> %arg, i64 0
81  %tmp1 = uitofp i8 %tmp to half
82  %tmp2 = insertelement <4 x half> undef, half %tmp1, i32 0
83  %tmp3 = extractelement <4 x i8> %arg, i64 1
84  %tmp4 = uitofp i8 %tmp3 to half
85  %tmp5 = insertelement <4 x half> %tmp2, half %tmp4, i32 1
86  %tmp6 = extractelement <4 x i8> %arg, i64 2
87  %tmp7 = uitofp i8 %tmp6 to half
88  %tmp8 = insertelement <4 x half> %tmp5, half %tmp7, i32 2
89  %tmp9 = extractelement <4 x i8> %arg, i64 3
90  %tmp10 = uitofp i8 %tmp9 to half
91  %tmp11 = insertelement <4 x half> %tmp8, half %tmp10, i32 3
92  ret <4 x half> %tmp11
93}
94
95declare half @llvm.fmuladd.f16(half, half, half)
96
97attributes #0 = { convergent nounwind readonly}
98attributes #1 = { norecurse nounwind readnone }
99