1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=i686-unknown | FileCheck %s --check-prefix=X32
3; RUN: llc < %s -mtriple=x86_64-unknown | FileCheck %s --check-prefix=X64
4
5; Use movzbl to avoid partial-register updates.
6
7define i32 @foo(i32 %p, i8 zeroext %x) nounwind {
8; X32-LABEL: foo:
9; X32:       # BB#0:
10; X32-NEXT:    movzbl {{[0-9]+}}(%esp), %eax
11; X32-NEXT:    divb {{[0-9]+}}(%esp)
12; X32-NEXT:    movzbl %al, %eax
13; X32-NEXT:    andl $1, %eax
14; X32-NEXT:    retl
15;
16; X64-LABEL: foo:
17; X64:       # BB#0:
18; X64-NEXT:    movzbl %dil, %eax
19; X64-NEXT:    divb %sil
20; X64-NEXT:    movzbl %al, %eax
21; X64-NEXT:    andl $1, %eax
22; X64-NEXT:    retq
23  %q = trunc i32 %p to i8
24  %r = udiv i8 %q, %x
25  %s = zext i8 %r to i32
26  %t = and i32 %s, 1
27  ret i32 %t
28}
29
30define i32 @bar(i32 %p, i16 zeroext %x) nounwind {
31; X32-LABEL: bar:
32; X32:       # BB#0:
33; X32-NEXT:    movw {{[0-9]+}}(%esp), %ax
34; X32-NEXT:    xorl %edx, %edx
35; X32-NEXT:    divw {{[0-9]+}}(%esp)
36; X32-NEXT:    andl $1, %eax
37; X32-NEXT:    retl
38;
39; X64-LABEL: bar:
40; X64:       # BB#0:
41; X64-NEXT:    xorl %edx, %edx
42; X64-NEXT:    movw %di, %ax
43; X64-NEXT:    divw %si
44; X64-NEXT:    andl $1, %eax
45; X64-NEXT:    retq
46  %q = trunc i32 %p to i16
47  %r = udiv i16 %q, %x
48  %s = zext i16 %r to i32
49  %t = and i32 %s, 1
50  ret i32 %t
51}
52