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
5 define i32 @mask_add_sext_i32_i64(ptr %base, i32 %i) {
6 ; X86-LABEL: mask_add_sext_i32_i64:
8 ; X86-NEXT: movsbl {{[0-9]+}}(%esp), %eax
9 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
10 ; X86-NEXT: movl 12(%ecx,%eax,4), %eax
13 ; X64-LABEL: mask_add_sext_i32_i64:
15 ; X64-NEXT: sarl $24, %esi
16 ; X64-NEXT: movslq %esi, %rax
17 ; X64-NEXT: movl 12(%rdi,%rax,4), %eax
19 %mask = ashr i32 %i, 24
20 %offset = add i32 %mask, 3
21 %sext = sext i32 %offset to i64
22 %gep = getelementptr i32, ptr %base, i64 %sext
23 %ret = load i32, ptr %gep
27 define i32 @mask_add_zext_i32_i64(ptr %base, i32 %i) {
28 ; X86-LABEL: mask_add_zext_i32_i64:
30 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
31 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
32 ; X86-NEXT: andl $15, %ecx
33 ; X86-NEXT: movl 12(%eax,%ecx,4), %eax
36 ; X64-LABEL: mask_add_zext_i32_i64:
38 ; X64-NEXT: # kill: def $esi killed $esi def $rsi
39 ; X64-NEXT: andl $15, %esi
40 ; X64-NEXT: movl 12(%rdi,%rsi,4), %eax
42 %mask = and i32 %i, 15
43 %offset = add i32 %mask, 3
44 %zext = zext i32 %offset to i64
45 %gep = getelementptr i32, ptr %base, i64 %zext
46 %ret = load i32, ptr %gep
50 define i32 @mask_offset_scale_zext_i32_i64(ptr %base, i32 %i) {
51 ; X86-LABEL: mask_offset_scale_zext_i32_i64:
53 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
54 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
55 ; X86-NEXT: shll $11, %ecx
56 ; X86-NEXT: movl 48(%eax,%ecx), %eax
59 ; X64-LABEL: mask_offset_scale_zext_i32_i64:
61 ; X64-NEXT: # kill: def $esi killed $esi def $rsi
62 ; X64-NEXT: andl $65280, %esi # imm = 0xFF00
63 ; X64-NEXT: movl 48(%rdi,%rsi,8), %eax
65 %mask = and i32 %i, 65280
66 %offset = or i32 %mask, 6
67 %scale = shl i32 %offset, 1
68 %idxprom = zext i32 %scale to i64
69 %arrayidx = getelementptr inbounds i32, ptr %base, i64 %idxprom
70 %load = load i32, ptr %arrayidx, align 4