@@ -17,6 +17,19 @@ define <vscale x 4 x i32> @binop_reverse(<vscale x 4 x i32> %a, <vscale x 4 x i3
17
17
ret <vscale x 4 x i32 > %add
18
18
}
19
19
20
+ define <vscale x 4 x i32 > @binop_intrinsic_reverse (<vscale x 4 x i32 > %a , <vscale x 4 x i32 > %b ) {
21
+ ; CHECK-LABEL: @binop_intrinsic_reverse(
22
+ ; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[A:%.*]])
23
+ ; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]])
24
+ ; CHECK-NEXT: [[ADD:%.*]] = call <vscale x 4 x i32> @llvm.smax.nxv4i32(<vscale x 4 x i32> [[A_REV]], <vscale x 4 x i32> [[B_REV]])
25
+ ; CHECK-NEXT: ret <vscale x 4 x i32> [[ADD]]
26
+ ;
27
+ %a.rev = tail call <vscale x 4 x i32 > @llvm.vector.reverse.nxv4i32 (<vscale x 4 x i32 > %a )
28
+ %b.rev = tail call <vscale x 4 x i32 > @llvm.vector.reverse.nxv4i32 (<vscale x 4 x i32 > %b )
29
+ %smax = call <vscale x 4 x i32 > @llvm.smax (<vscale x 4 x i32 > %a.rev , <vscale x 4 x i32 > %b.rev )
30
+ ret <vscale x 4 x i32 > %smax
31
+ }
32
+
20
33
; %a.rev has multiple uses
21
34
define <vscale x 4 x i32 > @binop_reverse_1 (<vscale x 4 x i32 > %a , <vscale x 4 x i32 > %b ) {
22
35
; CHECK-LABEL: @binop_reverse_1(
@@ -33,6 +46,22 @@ define <vscale x 4 x i32> @binop_reverse_1(<vscale x 4 x i32> %a, <vscale x 4 x
33
46
ret <vscale x 4 x i32 > %add
34
47
}
35
48
49
+ ; %a.rev has multiple uses
50
+ define <vscale x 4 x i32 > @binop_intrinsic_reverse_1 (<vscale x 4 x i32 > %a , <vscale x 4 x i32 > %b ) {
51
+ ; CHECK-LABEL: @binop_intrinsic_reverse_1(
52
+ ; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[A:%.*]])
53
+ ; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]])
54
+ ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[A_REV]])
55
+ ; CHECK-NEXT: [[SMAX:%.*]] = call <vscale x 4 x i32> @llvm.smax.nxv4i32(<vscale x 4 x i32> [[A_REV]], <vscale x 4 x i32> [[B_REV]])
56
+ ; CHECK-NEXT: ret <vscale x 4 x i32> [[SMAX]]
57
+ ;
58
+ %a.rev = tail call <vscale x 4 x i32 > @llvm.vector.reverse.nxv4i32 (<vscale x 4 x i32 > %a )
59
+ %b.rev = tail call <vscale x 4 x i32 > @llvm.vector.reverse.nxv4i32 (<vscale x 4 x i32 > %b )
60
+ call void @use_nxv4i32 (<vscale x 4 x i32 > %a.rev )
61
+ %smax = call <vscale x 4 x i32 > @llvm.smax (<vscale x 4 x i32 > %a.rev , <vscale x 4 x i32 > %b.rev )
62
+ ret <vscale x 4 x i32 > %smax
63
+ }
64
+
36
65
; %b.rev has multiple uses
37
66
define <vscale x 4 x i32 > @binop_reverse_2 (<vscale x 4 x i32 > %a , <vscale x 4 x i32 > %b ) {
38
67
; CHECK-LABEL: @binop_reverse_2(
@@ -67,6 +96,24 @@ define <vscale x 4 x i32> @binop_reverse_3(<vscale x 4 x i32> %a, <vscale x 4 x
67
96
ret <vscale x 4 x i32 > %add
68
97
}
69
98
99
+ ; %a.rev and %b.rev have multiple uses
100
+ define <vscale x 4 x i32 > @binop_intrinsic_reverse_3 (<vscale x 4 x i32 > %a , <vscale x 4 x i32 > %b ) {
101
+ ; CHECK-LABEL: @binop_intrinsic_reverse_3(
102
+ ; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[A:%.*]])
103
+ ; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> [[B:%.*]])
104
+ ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[A_REV]])
105
+ ; CHECK-NEXT: call void @use_nxv4i32(<vscale x 4 x i32> [[B_REV]])
106
+ ; CHECK-NEXT: [[SMAX:%.*]] = call <vscale x 4 x i32> @llvm.smax.nxv4i32(<vscale x 4 x i32> [[A_REV]], <vscale x 4 x i32> [[B_REV]])
107
+ ; CHECK-NEXT: ret <vscale x 4 x i32> [[SMAX]]
108
+ ;
109
+ %a.rev = tail call <vscale x 4 x i32 > @llvm.vector.reverse.nxv4i32 (<vscale x 4 x i32 > %a )
110
+ %b.rev = tail call <vscale x 4 x i32 > @llvm.vector.reverse.nxv4i32 (<vscale x 4 x i32 > %b )
111
+ call void @use_nxv4i32 (<vscale x 4 x i32 > %a.rev )
112
+ call void @use_nxv4i32 (<vscale x 4 x i32 > %b.rev )
113
+ %smax = call <vscale x 4 x i32 > @llvm.smax (<vscale x 4 x i32 > %a.rev , <vscale x 4 x i32 > %b.rev )
114
+ ret <vscale x 4 x i32 > %smax
115
+ }
116
+
70
117
; %a.rev used as both operands
71
118
define <vscale x 4 x i32 > @binop_reverse_4 (<vscale x 4 x i32 > %a ) {
72
119
; CHECK-LABEL: @binop_reverse_4(
@@ -184,6 +231,17 @@ define <vscale x 4 x float> @unop_reverse_1(<vscale x 4 x float> %a) {
184
231
ret <vscale x 4 x float > %neg
185
232
}
186
233
234
+ define <vscale x 4 x float > @unop_intrinsic_reverse (<vscale x 4 x float > %a ) {
235
+ ; CHECK-LABEL: @unop_intrinsic_reverse(
236
+ ; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> [[A:%.*]])
237
+ ; CHECK-NEXT: [[NEG:%.*]] = call <vscale x 4 x float> @llvm.fabs.nxv4f32(<vscale x 4 x float> [[A_REV]])
238
+ ; CHECK-NEXT: ret <vscale x 4 x float> [[NEG]]
239
+ ;
240
+ %a.rev = tail call <vscale x 4 x float > @llvm.vector.reverse.nxv4f32 (<vscale x 4 x float > %a )
241
+ %abs = call <vscale x 4 x float > @llvm.fabs (<vscale x 4 x float > %a.rev )
242
+ ret <vscale x 4 x float > %abs
243
+ }
244
+
187
245
define <vscale x 4 x i1 > @icmp_reverse (<vscale x 4 x i32 > %a , <vscale x 4 x i32 > %b ) {
188
246
; CHECK-LABEL: @icmp_reverse(
189
247
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq <vscale x 4 x i32> [[A:%.*]], [[B:%.*]]
@@ -629,6 +687,21 @@ define <vscale x 4 x float> @reverse_binop_reverse(<vscale x 4 x float> %a, <vsc
629
687
ret <vscale x 4 x float > %add.rev
630
688
}
631
689
690
+ define <vscale x 4 x float > @reverse_binop_intrinsic_reverse (<vscale x 4 x float > %a , <vscale x 4 x float > %b ) {
691
+ ; CHECK-LABEL: @reverse_binop_intrinsic_reverse(
692
+ ; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> [[A:%.*]])
693
+ ; CHECK-NEXT: [[B_REV:%.*]] = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> [[B:%.*]])
694
+ ; CHECK-NEXT: [[ADD:%.*]] = call <vscale x 4 x float> @llvm.maxnum.nxv4f32(<vscale x 4 x float> [[A_REV]], <vscale x 4 x float> [[B_REV]])
695
+ ; CHECK-NEXT: [[MAXNUM_REV:%.*]] = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> [[ADD]])
696
+ ; CHECK-NEXT: ret <vscale x 4 x float> [[MAXNUM_REV]]
697
+ ;
698
+ %a.rev = tail call <vscale x 4 x float > @llvm.vector.reverse.nxv4f32 (<vscale x 4 x float > %a )
699
+ %b.rev = tail call <vscale x 4 x float > @llvm.vector.reverse.nxv4f32 (<vscale x 4 x float > %b )
700
+ %maxnum = call <vscale x 4 x float > @llvm.maxnum.nxv4f32 (<vscale x 4 x float > %a.rev , <vscale x 4 x float > %b.rev )
701
+ %maxnum.rev = tail call <vscale x 4 x float > @llvm.vector.reverse.nxv4f32 (<vscale x 4 x float > %maxnum )
702
+ ret <vscale x 4 x float > %maxnum.rev
703
+ }
704
+
632
705
define <vscale x 4 x float > @reverse_binop_reverse_splat_RHS (<vscale x 4 x float > %a , float %b ) {
633
706
; CHECK-LABEL: @reverse_binop_reverse_splat_RHS(
634
707
; CHECK-NEXT: [[B_INSERT:%.*]] = insertelement <vscale x 4 x float> poison, float [[B:%.*]], i64 0
@@ -659,6 +732,53 @@ define <vscale x 4 x float> @reverse_binop_reverse_splat_LHS(<vscale x 4 x float
659
732
ret <vscale x 4 x float > %div.rev
660
733
}
661
734
735
+ define <vscale x 4 x float > @reverse_binop_reverse_intrinsic_splat_RHS (<vscale x 4 x float > %a , float %b ) {
736
+ ; CHECK-LABEL: @reverse_binop_reverse_intrinsic_splat_RHS(
737
+ ; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> [[A:%.*]])
738
+ ; CHECK-NEXT: [[B_INSERT:%.*]] = insertelement <vscale x 4 x float> poison, float [[B:%.*]], i64 0
739
+ ; CHECK-NEXT: [[B_SPLAT:%.*]] = shufflevector <vscale x 4 x float> [[B_INSERT]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
740
+ ; CHECK-NEXT: [[MAXNUM:%.*]] = call <vscale x 4 x float> @llvm.maxnum.nxv4f32(<vscale x 4 x float> [[A_REV]], <vscale x 4 x float> [[B_SPLAT]])
741
+ ; CHECK-NEXT: [[MAXNUM_REV:%.*]] = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> [[MAXNUM]])
742
+ ; CHECK-NEXT: ret <vscale x 4 x float> [[MAXNUM_REV]]
743
+ ;
744
+ %a.rev = tail call <vscale x 4 x float > @llvm.vector.reverse.nxv4f32 (<vscale x 4 x float > %a )
745
+ %b.insert = insertelement <vscale x 4 x float > poison, float %b , i32 0
746
+ %b.splat = shufflevector <vscale x 4 x float > %b.insert , <vscale x 4 x float > poison, <vscale x 4 x i32 > zeroinitializer
747
+ %maxnum = call <vscale x 4 x float > @llvm.maxnum.nxv4f32 (<vscale x 4 x float > %a.rev , <vscale x 4 x float > %b.splat )
748
+ %maxnum.rev = tail call <vscale x 4 x float > @llvm.vector.reverse.nxv4f32 (<vscale x 4 x float > %maxnum )
749
+ ret <vscale x 4 x float > %maxnum.rev
750
+ }
751
+
752
+ define <vscale x 4 x float > @reverse_binop_reverse_intrinsic_splat_LHS (<vscale x 4 x float > %a , float %b ) {
753
+ ; CHECK-LABEL: @reverse_binop_reverse_intrinsic_splat_LHS(
754
+ ; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> [[A:%.*]])
755
+ ; CHECK-NEXT: [[B_INSERT:%.*]] = insertelement <vscale x 4 x float> poison, float [[B:%.*]], i64 0
756
+ ; CHECK-NEXT: [[B_SPLAT:%.*]] = shufflevector <vscale x 4 x float> [[B_INSERT]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
757
+ ; CHECK-NEXT: [[MAXNUM:%.*]] = call <vscale x 4 x float> @llvm.maxnum.nxv4f32(<vscale x 4 x float> [[B_SPLAT]], <vscale x 4 x float> [[A_REV]])
758
+ ; CHECK-NEXT: [[MAXNUM_REV:%.*]] = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> [[MAXNUM]])
759
+ ; CHECK-NEXT: ret <vscale x 4 x float> [[MAXNUM_REV]]
760
+ ;
761
+ %a.rev = tail call <vscale x 4 x float > @llvm.vector.reverse.nxv4f32 (<vscale x 4 x float > %a )
762
+ %b.insert = insertelement <vscale x 4 x float > poison, float %b , i32 0
763
+ %b.splat = shufflevector <vscale x 4 x float > %b.insert , <vscale x 4 x float > poison, <vscale x 4 x i32 > zeroinitializer
764
+ %maxnum = call <vscale x 4 x float > @llvm.maxnum.nxv4f32 (<vscale x 4 x float > %b.splat , <vscale x 4 x float > %a.rev )
765
+ %maxnum.rev = tail call <vscale x 4 x float > @llvm.vector.reverse.nxv4f32 (<vscale x 4 x float > %maxnum )
766
+ ret <vscale x 4 x float > %maxnum.rev
767
+ }
768
+
769
+ define <4 x float > @reverse_binop_reverse_intrinsic_constant_RHS (<4 x float > %a ) {
770
+ ; CHECK-LABEL: @reverse_binop_reverse_intrinsic_constant_RHS(
771
+ ; CHECK-NEXT: [[MAXNUM_REV1:%.*]] = tail call <4 x float> @llvm.vector.reverse.v4f32(<4 x float> [[MAXNUM1:%.*]])
772
+ ; CHECK-NEXT: [[MAXNUM:%.*]] = call <4 x float> @llvm.maxnum.v4f32(<4 x float> [[MAXNUM_REV1]], <4 x float> <float 0.000000e+00, float 1.000000e+00, float 2.000000e+00, float 3.000000e+00>)
773
+ ; CHECK-NEXT: [[MAXNUM_REV:%.*]] = tail call <4 x float> @llvm.vector.reverse.v4f32(<4 x float> [[MAXNUM]])
774
+ ; CHECK-NEXT: ret <4 x float> [[MAXNUM_REV]]
775
+ ;
776
+ %a.rev = tail call <4 x float > @llvm.vector.reverse (<4 x float > %a )
777
+ %maxnum = call <4 x float > @llvm.maxnum.v4f32 (<4 x float > <float 0 .0 , float 1 .0 , float 2 .0 , float 3 .0 >, <4 x float > %a.rev )
778
+ %maxnum.rev = tail call <4 x float > @llvm.vector.reverse (<4 x float > %maxnum )
779
+ ret <4 x float > %maxnum.rev
780
+ }
781
+
662
782
define <vscale x 4 x i1 > @reverse_fcmp_reverse (<vscale x 4 x float > %a , <vscale x 4 x float > %b ) {
663
783
; CHECK-LABEL: @reverse_fcmp_reverse(
664
784
; CHECK-NEXT: [[CMP1:%.*]] = fcmp fast olt <vscale x 4 x float> [[A:%.*]], [[B:%.*]]
@@ -695,6 +815,31 @@ define <vscale x 4 x float> @reverse_unop_reverse(<vscale x 4 x float> %a) {
695
815
ret <vscale x 4 x float > %neg.rev
696
816
}
697
817
818
+ define <vscale x 4 x float > @reverse_unop_intrinsic_reverse (<vscale x 4 x float > %a ) {
819
+ ; CHECK-LABEL: @reverse_unop_intrinsic_reverse(
820
+ ; CHECK-NEXT: [[A_REV:%.*]] = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> [[A:%.*]])
821
+ ; CHECK-NEXT: [[ABS:%.*]] = call <vscale x 4 x float> @llvm.fabs.nxv4f32(<vscale x 4 x float> [[A_REV]])
822
+ ; CHECK-NEXT: [[ABS_REV:%.*]] = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> [[ABS]])
823
+ ; CHECK-NEXT: ret <vscale x 4 x float> [[ABS_REV]]
824
+ ;
825
+ %a.rev = tail call <vscale x 4 x float > @llvm.vector.reverse.nxv4f32 (<vscale x 4 x float > %a )
826
+ %abs = call <vscale x 4 x float > @llvm.fabs (<vscale x 4 x float > %a.rev )
827
+ %abs.rev = tail call <vscale x 4 x float > @llvm.vector.reverse.nxv4f32 (<vscale x 4 x float > %abs )
828
+ ret <vscale x 4 x float > %abs.rev
829
+ }
830
+
831
+ define <vscale x 4 x float > @reverse_unop_intrinsic_reverse_scalar_arg (<vscale x 4 x float > %a , i32 %power ) {
832
+ ; CHECK-LABEL: @reverse_unop_intrinsic_reverse_scalar_arg(
833
+ ; CHECK-NEXT: [[A:%.*]] = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> [[A1:%.*]])
834
+ ; CHECK-NEXT: [[TMP1:%.*]] = call <vscale x 4 x float> @llvm.powi.nxv4f32.i32(<vscale x 4 x float> [[A]], i32 [[POWER:%.*]])
835
+ ; CHECK-NEXT: [[POWI_REV:%.*]] = tail call <vscale x 4 x float> @llvm.vector.reverse.nxv4f32(<vscale x 4 x float> [[TMP1]])
836
+ ; CHECK-NEXT: ret <vscale x 4 x float> [[POWI_REV]]
837
+ ;
838
+ %a.rev = tail call <vscale x 4 x float > @llvm.vector.reverse.nxv4f32 (<vscale x 4 x float > %a )
839
+ %powi = call <vscale x 4 x float > @llvm.powi.nxv4f32 (<vscale x 4 x float > %a.rev , i32 %power )
840
+ %powi.rev = tail call <vscale x 4 x float > @llvm.vector.reverse.nxv4f32 (<vscale x 4 x float > %powi )
841
+ ret <vscale x 4 x float > %powi.rev
842
+ }
698
843
699
844
declare void @use_nxv4i1 (<vscale x 4 x i1 >)
700
845
declare void @use_nxv4i32 (<vscale x 4 x i32 >)
0 commit comments