1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=i686-unknown-unknown    | FileCheck %s -check-prefix=X32
3; RUN: llc < %s -mtriple=x86_64-unknown-unknown  | FileCheck %s -check-prefix=X64
4
5; DAGCombiner crashes during sext folding
6
7define <2 x i256> @test_sext1() {
8; X32-LABEL: test_sext1:
9; X32:       # %bb.0:
10; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
11; X32-NEXT:    movl $-1, 60(%eax)
12; X32-NEXT:    movl $-1, 56(%eax)
13; X32-NEXT:    movl $-1, 52(%eax)
14; X32-NEXT:    movl $-1, 48(%eax)
15; X32-NEXT:    movl $-1, 44(%eax)
16; X32-NEXT:    movl $-1, 40(%eax)
17; X32-NEXT:    movl $-1, 36(%eax)
18; X32-NEXT:    movl $-99, 32(%eax)
19; X32-NEXT:    movl $0, 28(%eax)
20; X32-NEXT:    movl $0, 24(%eax)
21; X32-NEXT:    movl $0, 20(%eax)
22; X32-NEXT:    movl $0, 16(%eax)
23; X32-NEXT:    movl $0, 12(%eax)
24; X32-NEXT:    movl $0, 8(%eax)
25; X32-NEXT:    movl $0, 4(%eax)
26; X32-NEXT:    movl $0, (%eax)
27; X32-NEXT:    retl $4
28;
29; X64-LABEL: test_sext1:
30; X64:       # %bb.0:
31; X64-NEXT:    movq %rdi, %rax
32; X64-NEXT:    xorps %xmm0, %xmm0
33; X64-NEXT:    movaps %xmm0, 16(%rdi)
34; X64-NEXT:    movaps %xmm0, (%rdi)
35; X64-NEXT:    movq $-1, 56(%rdi)
36; X64-NEXT:    movq $-1, 48(%rdi)
37; X64-NEXT:    movq $-1, 40(%rdi)
38; X64-NEXT:    movq $-99, 32(%rdi)
39; X64-NEXT:    retq
40  %Se = sext <2 x i8> <i8 -100, i8 -99> to <2 x i256>
41  %Shuff = shufflevector <2 x i256> zeroinitializer, <2 x i256> %Se, <2 x i32> <i32 1, i32 3>
42  ret <2 x i256> %Shuff
43}
44
45define <2 x i256> @test_sext2() {
46; X32-LABEL: test_sext2:
47; X32:       # %bb.0:
48; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
49; X32-NEXT:    movl $-1, 60(%eax)
50; X32-NEXT:    movl $-1, 56(%eax)
51; X32-NEXT:    movl $-1, 52(%eax)
52; X32-NEXT:    movl $-1, 48(%eax)
53; X32-NEXT:    movl $-1, 44(%eax)
54; X32-NEXT:    movl $-1, 40(%eax)
55; X32-NEXT:    movl $-1, 36(%eax)
56; X32-NEXT:    movl $-1999, 32(%eax) # imm = 0xF831
57; X32-NEXT:    movl $0, 28(%eax)
58; X32-NEXT:    movl $0, 24(%eax)
59; X32-NEXT:    movl $0, 20(%eax)
60; X32-NEXT:    movl $0, 16(%eax)
61; X32-NEXT:    movl $0, 12(%eax)
62; X32-NEXT:    movl $0, 8(%eax)
63; X32-NEXT:    movl $0, 4(%eax)
64; X32-NEXT:    movl $0, (%eax)
65; X32-NEXT:    retl $4
66;
67; X64-LABEL: test_sext2:
68; X64:       # %bb.0:
69; X64-NEXT:    movq %rdi, %rax
70; X64-NEXT:    xorps %xmm0, %xmm0
71; X64-NEXT:    movaps %xmm0, 16(%rdi)
72; X64-NEXT:    movaps %xmm0, (%rdi)
73; X64-NEXT:    movq $-1, 56(%rdi)
74; X64-NEXT:    movq $-1, 48(%rdi)
75; X64-NEXT:    movq $-1, 40(%rdi)
76; X64-NEXT:    movq $-1999, 32(%rdi) # imm = 0xF831
77; X64-NEXT:    retq
78  %Se = sext <2 x i128> <i128 -2000, i128 -1999> to <2 x i256>
79  %Shuff = shufflevector <2 x i256> zeroinitializer, <2 x i256> %Se, <2 x i32> <i32 1, i32 3>
80  ret <2 x i256> %Shuff
81}
82
83define <2 x i256> @test_zext1() {
84; X32-LABEL: test_zext1:
85; X32:       # %bb.0:
86; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
87; X32-NEXT:    movl $0, 60(%eax)
88; X32-NEXT:    movl $0, 56(%eax)
89; X32-NEXT:    movl $0, 52(%eax)
90; X32-NEXT:    movl $0, 48(%eax)
91; X32-NEXT:    movl $0, 44(%eax)
92; X32-NEXT:    movl $0, 40(%eax)
93; X32-NEXT:    movl $0, 36(%eax)
94; X32-NEXT:    movl $254, 32(%eax)
95; X32-NEXT:    movl $0, 28(%eax)
96; X32-NEXT:    movl $0, 24(%eax)
97; X32-NEXT:    movl $0, 20(%eax)
98; X32-NEXT:    movl $0, 16(%eax)
99; X32-NEXT:    movl $0, 12(%eax)
100; X32-NEXT:    movl $0, 8(%eax)
101; X32-NEXT:    movl $0, 4(%eax)
102; X32-NEXT:    movl $0, (%eax)
103; X32-NEXT:    retl $4
104;
105; X64-LABEL: test_zext1:
106; X64:       # %bb.0:
107; X64-NEXT:    movq %rdi, %rax
108; X64-NEXT:    xorps %xmm0, %xmm0
109; X64-NEXT:    movaps %xmm0, 48(%rdi)
110; X64-NEXT:    movaps %xmm0, 16(%rdi)
111; X64-NEXT:    movaps %xmm0, (%rdi)
112; X64-NEXT:    movq $0, 40(%rdi)
113; X64-NEXT:    movq $254, 32(%rdi)
114; X64-NEXT:    retq
115  %Se = zext <2 x i8> <i8 -1, i8 -2> to <2 x i256>
116  %Shuff = shufflevector <2 x i256> zeroinitializer, <2 x i256> %Se, <2 x i32> <i32 1, i32 3>
117  ret <2 x i256> %Shuff
118}
119
120define <2 x i256> @test_zext2() {
121; X32-LABEL: test_zext2:
122; X32:       # %bb.0:
123; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
124; X32-NEXT:    movl $0, 60(%eax)
125; X32-NEXT:    movl $0, 56(%eax)
126; X32-NEXT:    movl $0, 52(%eax)
127; X32-NEXT:    movl $0, 48(%eax)
128; X32-NEXT:    movl $-1, 44(%eax)
129; X32-NEXT:    movl $-1, 40(%eax)
130; X32-NEXT:    movl $-1, 36(%eax)
131; X32-NEXT:    movl $-2, 32(%eax)
132; X32-NEXT:    movl $0, 28(%eax)
133; X32-NEXT:    movl $0, 24(%eax)
134; X32-NEXT:    movl $0, 20(%eax)
135; X32-NEXT:    movl $0, 16(%eax)
136; X32-NEXT:    movl $0, 12(%eax)
137; X32-NEXT:    movl $0, 8(%eax)
138; X32-NEXT:    movl $0, 4(%eax)
139; X32-NEXT:    movl $0, (%eax)
140; X32-NEXT:    retl $4
141;
142; X64-LABEL: test_zext2:
143; X64:       # %bb.0:
144; X64-NEXT:    movq %rdi, %rax
145; X64-NEXT:    xorps %xmm0, %xmm0
146; X64-NEXT:    movaps %xmm0, 48(%rdi)
147; X64-NEXT:    movaps %xmm0, 16(%rdi)
148; X64-NEXT:    movaps %xmm0, (%rdi)
149; X64-NEXT:    movq $-1, 40(%rdi)
150; X64-NEXT:    movq $-2, 32(%rdi)
151; X64-NEXT:    retq
152  %Se = zext <2 x i128> <i128 -1, i128 -2> to <2 x i256>
153  %Shuff = shufflevector <2 x i256> zeroinitializer, <2 x i256> %Se, <2 x i32> <i32 1, i32 3>
154  ret <2 x i256> %Shuff
155}
156