Skip to content

Commit 43017ce

Browse files
committed
[PhaseOrdering] add vector reduction tests; NFC
These are based on tests originally included in: D79078
1 parent 604f449 commit 43017ce

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2+
; RUN: opt -O2 -S -mattr=avx < %s | FileCheck %s
3+
; RUN: opt -passes='default<O2>' -S -mattr=avx < %s | FileCheck %s
4+
5+
target triple = "x86_64--"
6+
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
7+
8+
define i32 @ext_ext_or_reduction_v4i32(<4 x i32> %x, <4 x i32> %y) {
9+
; CHECK-LABEL: @ext_ext_or_reduction_v4i32(
10+
; CHECK-NEXT: [[Z:%.*]] = and <4 x i32> [[Y:%.*]], [[X:%.*]]
11+
; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <4 x i32> [[Z]], <4 x i32> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>
12+
; CHECK-NEXT: [[TMP2:%.*]] = or <4 x i32> [[Z]], [[TMP1]]
13+
; CHECK-NEXT: [[TMP3:%.*]] = extractelement <4 x i32> [[TMP2]], i32 0
14+
; CHECK-NEXT: [[Z2:%.*]] = extractelement <4 x i32> [[Z]], i32 2
15+
; CHECK-NEXT: [[Z012:%.*]] = or i32 [[TMP3]], [[Z2]]
16+
; CHECK-NEXT: [[Z3:%.*]] = extractelement <4 x i32> [[Z]], i32 3
17+
; CHECK-NEXT: [[Z0123:%.*]] = or i32 [[Z012]], [[Z3]]
18+
; CHECK-NEXT: ret i32 [[Z0123]]
19+
;
20+
%z = and <4 x i32> %x, %y
21+
%z0 = extractelement <4 x i32> %z, i32 0
22+
%z1 = extractelement <4 x i32> %z, i32 1
23+
%z01 = or i32 %z0, %z1
24+
%z2 = extractelement <4 x i32> %z, i32 2
25+
%z012 = or i32 %z01, %z2
26+
%z3 = extractelement <4 x i32> %z, i32 3
27+
%z0123 = or i32 %z3, %z012
28+
ret i32 %z0123
29+
}
30+
31+
define i32 @ext_ext_partial_add_reduction_v4i32(<4 x i32> %x) {
32+
; CHECK-LABEL: @ext_ext_partial_add_reduction_v4i32(
33+
; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>
34+
; CHECK-NEXT: [[TMP2:%.*]] = add <4 x i32> [[TMP1]], [[X]]
35+
; CHECK-NEXT: [[TMP3:%.*]] = extractelement <4 x i32> [[TMP2]], i64 0
36+
; CHECK-NEXT: [[X2:%.*]] = extractelement <4 x i32> [[X]], i32 2
37+
; CHECK-NEXT: [[X210:%.*]] = add i32 [[TMP3]], [[X2]]
38+
; CHECK-NEXT: ret i32 [[X210]]
39+
;
40+
%x0 = extractelement <4 x i32> %x, i32 0
41+
%x1 = extractelement <4 x i32> %x, i32 1
42+
%x10 = add i32 %x1, %x0
43+
%x2 = extractelement <4 x i32> %x, i32 2
44+
%x210 = add i32 %x2, %x10
45+
ret i32 %x210
46+
}
47+
48+
define i32 @ext_ext_partial_add_reduction_and_extra_add_v4i32(<4 x i32> %x, <4 x i32> %y) {
49+
; CHECK-LABEL: @ext_ext_partial_add_reduction_and_extra_add_v4i32(
50+
; CHECK-NEXT: [[Y1:%.*]] = extractelement <4 x i32> [[Y:%.*]], i32 1
51+
; CHECK-NEXT: [[Y2:%.*]] = extractelement <4 x i32> [[Y]], i32 2
52+
; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> undef, <4 x i32> <i32 2, i32 undef, i32 undef, i32 undef>
53+
; CHECK-NEXT: [[TMP2:%.*]] = add <4 x i32> [[TMP1]], [[Y]]
54+
; CHECK-NEXT: [[TMP3:%.*]] = extractelement <4 x i32> [[TMP2]], i32 0
55+
; CHECK-NEXT: [[Y210:%.*]] = add i32 [[TMP3]], [[Y1]]
56+
; CHECK-NEXT: [[X2Y210:%.*]] = add i32 [[Y210]], [[Y2]]
57+
; CHECK-NEXT: ret i32 [[X2Y210]]
58+
;
59+
%y0 = extractelement <4 x i32> %y, i32 0
60+
%y1 = extractelement <4 x i32> %y, i32 1
61+
%y10 = add i32 %y1, %y0
62+
%y2 = extractelement <4 x i32> %y, i32 2
63+
%y210 = add i32 %y2, %y10
64+
%x2 = extractelement <4 x i32> %x, i32 2
65+
%x2y210 = add i32 %x2, %y210
66+
ret i32 %x2y210
67+
}

0 commit comments

Comments
 (0)