Skip to content

Commit 1ae4ddc

Browse files
committed
Precommit tests
1 parent 003145d commit 1ae4ddc

File tree

1 file changed

+145
-0
lines changed

1 file changed

+145
-0
lines changed

llvm/test/Transforms/InstCombine/vector-reverse.ll

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ define <vscale x 4 x i32> @binop_reverse(<vscale x 4 x i32> %a, <vscale x 4 x i3
1717
ret <vscale x 4 x i32> %add
1818
}
1919

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+
2033
; %a.rev has multiple uses
2134
define <vscale x 4 x i32> @binop_reverse_1(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
2235
; 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
3346
ret <vscale x 4 x i32> %add
3447
}
3548

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+
3665
; %b.rev has multiple uses
3766
define <vscale x 4 x i32> @binop_reverse_2(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
3867
; 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
6796
ret <vscale x 4 x i32> %add
6897
}
6998

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+
70117
; %a.rev used as both operands
71118
define <vscale x 4 x i32> @binop_reverse_4(<vscale x 4 x i32> %a) {
72119
; CHECK-LABEL: @binop_reverse_4(
@@ -184,6 +231,17 @@ define <vscale x 4 x float> @unop_reverse_1(<vscale x 4 x float> %a) {
184231
ret <vscale x 4 x float> %neg
185232
}
186233

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+
187245
define <vscale x 4 x i1> @icmp_reverse(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
188246
; CHECK-LABEL: @icmp_reverse(
189247
; 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
629687
ret <vscale x 4 x float> %add.rev
630688
}
631689

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+
632705
define <vscale x 4 x float> @reverse_binop_reverse_splat_RHS(<vscale x 4 x float> %a, float %b) {
633706
; CHECK-LABEL: @reverse_binop_reverse_splat_RHS(
634707
; 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
659732
ret <vscale x 4 x float> %div.rev
660733
}
661734

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+
662782
define <vscale x 4 x i1> @reverse_fcmp_reverse(<vscale x 4 x float> %a, <vscale x 4 x float> %b) {
663783
; CHECK-LABEL: @reverse_fcmp_reverse(
664784
; 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) {
695815
ret <vscale x 4 x float> %neg.rev
696816
}
697817

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+
}
698843

699844
declare void @use_nxv4i1(<vscale x 4 x i1>)
700845
declare void @use_nxv4i32(<vscale x 4 x i32>)

0 commit comments

Comments
 (0)