xref: /llvm-project/llvm/test/CodeGen/X86/anyext.ll (revision ccb2810ee33588ad0707e51bb31af8fec5e39f76)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=i686-unknown | FileCheck %s --check-prefix=X86
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; X86-LABEL: foo:
9; X86:       # %bb.0:
10; X86-NEXT:    movzbl {{[0-9]+}}(%esp), %eax
11; X86-NEXT:    divb {{[0-9]+}}(%esp)
12; X86-NEXT:    movzbl %al, %eax
13; X86-NEXT:    andl $1, %eax
14; X86-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; X86-LABEL: bar:
32; X86:       # %bb.0:
33; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
34; X86-NEXT:    xorl %edx, %edx
35; X86-NEXT:    divw {{[0-9]+}}(%esp)
36; X86-NEXT:    # kill: def $ax killed $ax def $eax
37; X86-NEXT:    andl $1, %eax
38; X86-NEXT:    retl
39;
40; X64-LABEL: bar:
41; X64:       # %bb.0:
42; X64-NEXT:    movl %edi, %eax
43; X64-NEXT:    # kill: def $ax killed $ax killed $eax
44; X64-NEXT:    xorl %edx, %edx
45; X64-NEXT:    divw %si
46; X64-NEXT:    # kill: def $ax killed $ax def $eax
47; X64-NEXT:    andl $1, %eax
48; X64-NEXT:    retq
49  %q = trunc i32 %p to i16
50  %r = udiv i16 %q, %x
51  %s = zext i16 %r to i32
52  %t = and i32 %s, 1
53  ret i32 %t
54}
55