1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2;
3; PR30298: Check if the target doesn't have SSE2, compiler will not crash
4; or generate incorrect code because of vector mul width shrinking optimization.
5;
6; RUN: llc -mtriple=i386-pc-linux-gnu -mattr=+sse < %s | FileCheck %s
7
8@c = external dso_local global i32*, align 8
9
10define void @mul_2xi8(i8* nocapture readonly %a, i8* nocapture readonly %b, i64 %index) nounwind {
11; CHECK-LABEL: mul_2xi8:
12; CHECK:       # %bb.0: # %entry
13; CHECK-NEXT:    pushl %ebx
14; CHECK-NEXT:    pushl %edi
15; CHECK-NEXT:    pushl %esi
16; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %eax
17; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %ecx
18; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %edx
19; CHECK-NEXT:    movl c, %esi
20; CHECK-NEXT:    movzbl 1(%edx,%ecx), %edi
21; CHECK-NEXT:    movzbl (%edx,%ecx), %edx
22; CHECK-NEXT:    movzbl 1(%eax,%ecx), %ebx
23; CHECK-NEXT:    imull %edi, %ebx
24; CHECK-NEXT:    movzbl (%eax,%ecx), %eax
25; CHECK-NEXT:    imull %edx, %eax
26; CHECK-NEXT:    movl %ebx, 4(%esi,%ecx,4)
27; CHECK-NEXT:    movl %eax, (%esi,%ecx,4)
28; CHECK-NEXT:    popl %esi
29; CHECK-NEXT:    popl %edi
30; CHECK-NEXT:    popl %ebx
31; CHECK-NEXT:    retl
32entry:
33  %pre = load i32*, i32** @c
34  %tmp6 = getelementptr inbounds i8, i8* %a, i64 %index
35  %tmp7 = bitcast i8* %tmp6 to <2 x i8>*
36  %wide.load = load <2 x i8>, <2 x i8>* %tmp7, align 1
37  %tmp8 = zext <2 x i8> %wide.load to <2 x i32>
38  %tmp10 = getelementptr inbounds i8, i8* %b, i64 %index
39  %tmp11 = bitcast i8* %tmp10 to <2 x i8>*
40  %wide.load17 = load <2 x i8>, <2 x i8>* %tmp11, align 1
41  %tmp12 = zext <2 x i8> %wide.load17 to <2 x i32>
42  %tmp13 = mul nuw nsw <2 x i32> %tmp12, %tmp8
43  %tmp14 = getelementptr inbounds i32, i32* %pre, i64 %index
44  %tmp15 = bitcast i32* %tmp14 to <2 x i32>*
45  store <2 x i32> %tmp13, <2 x i32>* %tmp15, align 4
46  ret void
47}
48