xref: /llvm-project/llvm/test/Transforms/LowerMatrixIntrinsics/transpose-float.ll (revision 8b56da5e9f3ba737a5ff4bf5dee654416849042f)
1526244b1SFlorian Hahn; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2526244b1SFlorian Hahn; RUN: opt -passes='lower-matrix-intrinsics' -S < %s | FileCheck %s
3526244b1SFlorian Hahn
4526244b1SFlorian Hahn
5526244b1SFlorian Hahndefine <8 x float> @transpose(<8 x float> %a) {
6526244b1SFlorian Hahn; CHECK-LABEL: @transpose(
7526244b1SFlorian Hahn; CHECK-NEXT:  entry:
89b296102SJuneyoung Lee; CHECK-NEXT:    [[SPLIT:%.*]] = shufflevector <8 x float> [[A:%.*]], <8 x float> poison, <2 x i32> <i32 0, i32 1>
99b296102SJuneyoung Lee; CHECK-NEXT:    [[SPLIT1:%.*]] = shufflevector <8 x float> [[A]], <8 x float> poison, <2 x i32> <i32 2, i32 3>
109b296102SJuneyoung Lee; CHECK-NEXT:    [[SPLIT2:%.*]] = shufflevector <8 x float> [[A]], <8 x float> poison, <2 x i32> <i32 4, i32 5>
119b296102SJuneyoung Lee; CHECK-NEXT:    [[SPLIT3:%.*]] = shufflevector <8 x float> [[A]], <8 x float> poison, <2 x i32> <i32 6, i32 7>
12526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP0:%.*]] = extractelement <2 x float> [[SPLIT]], i64 0
13022bd92cSNuno Lopes; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <4 x float> poison, float [[TMP0]], i64 0
14526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP2:%.*]] = extractelement <2 x float> [[SPLIT1]], i64 0
15526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP3:%.*]] = insertelement <4 x float> [[TMP1]], float [[TMP2]], i64 1
16526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP4:%.*]] = extractelement <2 x float> [[SPLIT2]], i64 0
17526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP5:%.*]] = insertelement <4 x float> [[TMP3]], float [[TMP4]], i64 2
18526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP6:%.*]] = extractelement <2 x float> [[SPLIT3]], i64 0
19526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP7:%.*]] = insertelement <4 x float> [[TMP5]], float [[TMP6]], i64 3
20526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP8:%.*]] = extractelement <2 x float> [[SPLIT]], i64 1
21022bd92cSNuno Lopes; CHECK-NEXT:    [[TMP9:%.*]] = insertelement <4 x float> poison, float [[TMP8]], i64 0
22526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP10:%.*]] = extractelement <2 x float> [[SPLIT1]], i64 1
23526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP11:%.*]] = insertelement <4 x float> [[TMP9]], float [[TMP10]], i64 1
24526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP12:%.*]] = extractelement <2 x float> [[SPLIT2]], i64 1
25526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP13:%.*]] = insertelement <4 x float> [[TMP11]], float [[TMP12]], i64 2
26526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP14:%.*]] = extractelement <2 x float> [[SPLIT3]], i64 1
27526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP15:%.*]] = insertelement <4 x float> [[TMP13]], float [[TMP14]], i64 3
28526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP16:%.*]] = shufflevector <4 x float> [[TMP7]], <4 x float> [[TMP15]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
29526244b1SFlorian Hahn; CHECK-NEXT:    ret <8 x float> [[TMP16]]
30526244b1SFlorian Hahn;
31526244b1SFlorian Hahnentry:
32526244b1SFlorian Hahn  %c  = call <8 x float> @llvm.matrix.transpose(<8 x float> %a, i32 2, i32 4)
33526244b1SFlorian Hahn  ret <8 x float> %c
34526244b1SFlorian Hahn}
35526244b1SFlorian Hahn
36526244b1SFlorian Hahndeclare <8 x float> @llvm.matrix.transpose(<8 x float>, i32, i32)
37526244b1SFlorian Hahn
38526244b1SFlorian Hahndefine <8 x float> @transpose_single_column(<8 x float> %a) {
39526244b1SFlorian Hahn; CHECK-LABEL: @transpose_single_column(
40526244b1SFlorian Hahn; CHECK-NEXT:  entry:
419b296102SJuneyoung Lee; CHECK-NEXT:    [[SPLIT:%.*]] = shufflevector <8 x float> [[A:%.*]], <8 x float> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
42526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP0:%.*]] = extractelement <8 x float> [[SPLIT]], i64 0
43022bd92cSNuno Lopes; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <1 x float> poison, float [[TMP0]], i64 0
44526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP2:%.*]] = extractelement <8 x float> [[SPLIT]], i64 1
45022bd92cSNuno Lopes; CHECK-NEXT:    [[TMP3:%.*]] = insertelement <1 x float> poison, float [[TMP2]], i64 0
46526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP4:%.*]] = extractelement <8 x float> [[SPLIT]], i64 2
47022bd92cSNuno Lopes; CHECK-NEXT:    [[TMP5:%.*]] = insertelement <1 x float> poison, float [[TMP4]], i64 0
48526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP6:%.*]] = extractelement <8 x float> [[SPLIT]], i64 3
49022bd92cSNuno Lopes; CHECK-NEXT:    [[TMP7:%.*]] = insertelement <1 x float> poison, float [[TMP6]], i64 0
50526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP8:%.*]] = extractelement <8 x float> [[SPLIT]], i64 4
51022bd92cSNuno Lopes; CHECK-NEXT:    [[TMP9:%.*]] = insertelement <1 x float> poison, float [[TMP8]], i64 0
52526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP10:%.*]] = extractelement <8 x float> [[SPLIT]], i64 5
53022bd92cSNuno Lopes; CHECK-NEXT:    [[TMP11:%.*]] = insertelement <1 x float> poison, float [[TMP10]], i64 0
54526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP12:%.*]] = extractelement <8 x float> [[SPLIT]], i64 6
55022bd92cSNuno Lopes; CHECK-NEXT:    [[TMP13:%.*]] = insertelement <1 x float> poison, float [[TMP12]], i64 0
56526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP14:%.*]] = extractelement <8 x float> [[SPLIT]], i64 7
57022bd92cSNuno Lopes; CHECK-NEXT:    [[TMP15:%.*]] = insertelement <1 x float> poison, float [[TMP14]], i64 0
58526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP16:%.*]] = shufflevector <1 x float> [[TMP1]], <1 x float> [[TMP3]], <2 x i32> <i32 0, i32 1>
59526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP17:%.*]] = shufflevector <1 x float> [[TMP5]], <1 x float> [[TMP7]], <2 x i32> <i32 0, i32 1>
60526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP18:%.*]] = shufflevector <1 x float> [[TMP9]], <1 x float> [[TMP11]], <2 x i32> <i32 0, i32 1>
61526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP19:%.*]] = shufflevector <1 x float> [[TMP13]], <1 x float> [[TMP15]], <2 x i32> <i32 0, i32 1>
62526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP20:%.*]] = shufflevector <2 x float> [[TMP16]], <2 x float> [[TMP17]], <4 x i32> <i32 0, i32 1, i32 2, i32 3>
63526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP21:%.*]] = shufflevector <2 x float> [[TMP18]], <2 x float> [[TMP19]], <4 x i32> <i32 0, i32 1, i32 2, i32 3>
64526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP22:%.*]] = shufflevector <4 x float> [[TMP20]], <4 x float> [[TMP21]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
65526244b1SFlorian Hahn; CHECK-NEXT:    ret <8 x float> [[TMP22]]
66526244b1SFlorian Hahn;
67526244b1SFlorian Hahnentry:
68526244b1SFlorian Hahn  %c  = call <8 x float> @llvm.matrix.transpose(<8 x float> %a, i32 8, i32 1)
69526244b1SFlorian Hahn  ret <8 x float> %c
70526244b1SFlorian Hahn}
71526244b1SFlorian Hahn
72526244b1SFlorian Hahndeclare <12 x float> @llvm.matrix.transpose.v12f32(<12 x float>, i32, i32)
73526244b1SFlorian Hahn
74526244b1SFlorian Hahndefine <12 x float> @transpose_float_3x4(<12 x float> %a) {
75526244b1SFlorian Hahn; CHECK-LABEL: @transpose_float_3x4(
76526244b1SFlorian Hahn; CHECK-NEXT:  entry:
779b296102SJuneyoung Lee; CHECK-NEXT:    [[SPLIT:%.*]] = shufflevector <12 x float> [[A:%.*]], <12 x float> poison, <3 x i32> <i32 0, i32 1, i32 2>
789b296102SJuneyoung Lee; CHECK-NEXT:    [[SPLIT1:%.*]] = shufflevector <12 x float> [[A]], <12 x float> poison, <3 x i32> <i32 3, i32 4, i32 5>
799b296102SJuneyoung Lee; CHECK-NEXT:    [[SPLIT2:%.*]] = shufflevector <12 x float> [[A]], <12 x float> poison, <3 x i32> <i32 6, i32 7, i32 8>
809b296102SJuneyoung Lee; CHECK-NEXT:    [[SPLIT3:%.*]] = shufflevector <12 x float> [[A]], <12 x float> poison, <3 x i32> <i32 9, i32 10, i32 11>
81526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP0:%.*]] = extractelement <3 x float> [[SPLIT]], i64 0
82022bd92cSNuno Lopes; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <4 x float> poison, float [[TMP0]], i64 0
83526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP2:%.*]] = extractelement <3 x float> [[SPLIT1]], i64 0
84526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP3:%.*]] = insertelement <4 x float> [[TMP1]], float [[TMP2]], i64 1
85526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP4:%.*]] = extractelement <3 x float> [[SPLIT2]], i64 0
86526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP5:%.*]] = insertelement <4 x float> [[TMP3]], float [[TMP4]], i64 2
87526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP6:%.*]] = extractelement <3 x float> [[SPLIT3]], i64 0
88526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP7:%.*]] = insertelement <4 x float> [[TMP5]], float [[TMP6]], i64 3
89526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP8:%.*]] = extractelement <3 x float> [[SPLIT]], i64 1
90022bd92cSNuno Lopes; CHECK-NEXT:    [[TMP9:%.*]] = insertelement <4 x float> poison, float [[TMP8]], i64 0
91526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP10:%.*]] = extractelement <3 x float> [[SPLIT1]], i64 1
92526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP11:%.*]] = insertelement <4 x float> [[TMP9]], float [[TMP10]], i64 1
93526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP12:%.*]] = extractelement <3 x float> [[SPLIT2]], i64 1
94526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP13:%.*]] = insertelement <4 x float> [[TMP11]], float [[TMP12]], i64 2
95526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP14:%.*]] = extractelement <3 x float> [[SPLIT3]], i64 1
96526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP15:%.*]] = insertelement <4 x float> [[TMP13]], float [[TMP14]], i64 3
97526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP16:%.*]] = extractelement <3 x float> [[SPLIT]], i64 2
98022bd92cSNuno Lopes; CHECK-NEXT:    [[TMP17:%.*]] = insertelement <4 x float> poison, float [[TMP16]], i64 0
99526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP18:%.*]] = extractelement <3 x float> [[SPLIT1]], i64 2
100526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP19:%.*]] = insertelement <4 x float> [[TMP17]], float [[TMP18]], i64 1
101526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP20:%.*]] = extractelement <3 x float> [[SPLIT2]], i64 2
102526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP21:%.*]] = insertelement <4 x float> [[TMP19]], float [[TMP20]], i64 2
103526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP22:%.*]] = extractelement <3 x float> [[SPLIT3]], i64 2
104526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP23:%.*]] = insertelement <4 x float> [[TMP21]], float [[TMP22]], i64 3
105526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP24:%.*]] = shufflevector <4 x float> [[TMP7]], <4 x float> [[TMP15]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
106*8b56da5eSManuelJBrito; CHECK-NEXT:    [[TMP25:%.*]] = shufflevector <4 x float> [[TMP23]], <4 x float> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison>
107526244b1SFlorian Hahn; CHECK-NEXT:    [[TMP26:%.*]] = shufflevector <8 x float> [[TMP24]], <8 x float> [[TMP25]], <12 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11>
108526244b1SFlorian Hahn; CHECK-NEXT:    ret <12 x float> [[TMP26]]
109526244b1SFlorian Hahn;
110526244b1SFlorian Hahnentry:
111526244b1SFlorian Hahn  %c  = call <12 x float> @llvm.matrix.transpose.v12f32(<12 x float> %a, i32 3, i32 4)
112526244b1SFlorian Hahn  ret <12 x float> %c
113526244b1SFlorian Hahn}
114