1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=i686-- | FileCheck %s --check-prefixes=X86
; RUN: llc < %s -mtriple=x86_64-- | FileCheck %s --check-prefixes=X64
; Fold and(sextinreg(v0,i5),sextinreg(v1,i5)) -> sextinreg(and(v0,v1),i5)
define i32 @sextinreg_i32(ptr %p0, ptr %p1) {
; X86-LABEL: sextinreg_i32:
; X86: # %bb.0:
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
; X86-NEXT: movzbl (%ecx), %ecx
; X86-NEXT: movzbl (%eax), %eax
; X86-NEXT: andl %ecx, %eax
; X86-NEXT: shll $27, %eax
; X86-NEXT: sarl $27, %eax
; X86-NEXT: retl
;
; X64-LABEL: sextinreg_i32:
; X64: # %bb.0:
; X64-NEXT: movzbl (%rdi), %ecx
; X64-NEXT: movzbl (%rsi), %eax
; X64-NEXT: andl %ecx, %eax
; X64-NEXT: shll $27, %eax
; X64-NEXT: sarl $27, %eax
; X64-NEXT: retq
%v0 = load i8, ptr %p0, align 1
%v1 = load i8, ptr %p1, align 1
%x0 = zext i8 %v0 to i32
%x1 = zext i8 %v1 to i32
%l0 = shl i32 %x0, 27
%l1 = shl i32 %x1, 27
%a0 = ashr exact i32 %l0, 27
%a1 = ashr exact i32 %l1, 27
%and = and i32 %a0, %a1
ret i32 %and
}
; MISMATCH and(sextinreg(v0,i2),sextinreg(v1,i5)) != sextinreg(and(v0,v1),i2)
define i32 @sextinreg_i32_mismatch(ptr %p0, ptr %p1) {
; X86-LABEL: sextinreg_i32_mismatch:
; X86: # %bb.0:
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
; X86-NEXT: movzbl (%ecx), %ecx
; X86-NEXT: movzbl (%eax), %eax
; X86-NEXT: shll $30, %ecx
; X86-NEXT: sarl $30, %ecx
; X86-NEXT: shll $27, %eax
; X86-NEXT: sarl $27, %eax
; X86-NEXT: andl %ecx, %eax
; X86-NEXT: retl
;
; X64-LABEL: sextinreg_i32_mismatch:
; X64: # %bb.0:
; X64-NEXT: movzbl (%rdi), %ecx
; X64-NEXT: movzbl (%rsi), %eax
; X64-NEXT: shll $30, %ecx
; X64-NEXT: sarl $30, %ecx
; X64-NEXT: shll $27, %eax
; X64-NEXT: sarl $27, %eax
; X64-NEXT: andl %ecx, %eax
; X64-NEXT: retq
%v0 = load i8, ptr %p0, align 1
%v1 = load i8, ptr %p1, align 1
%x0 = zext i8 %v0 to i32
%x1 = zext i8 %v1 to i32
%l0 = shl i32 %x0, 30
%l1 = shl i32 %x1, 27
%a0 = ashr exact i32 %l0, 30
%a1 = ashr exact i32 %l1, 27
%and = and i32 %a0, %a1
ret i32 %and
}
|