1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s
5 define i64 @test1(i8* %data) {
7 ; CHECK: # %bb.0: # %entry
8 ; CHECK-NEXT: movl (%rdi), %eax
9 ; CHECK-NEXT: shll $2, %eax
10 ; CHECK-NEXT: andl $60, %eax
13 %bf.load = load i8, i8* %data, align 4
14 %bf.clear = shl i8 %bf.load, 2
15 %0 = and i8 %bf.clear, 60
16 %mul = zext i8 %0 to i64
20 define i8* @test2(i8* %data) {
22 ; CHECK: # %bb.0: # %entry
23 ; CHECK-NEXT: movl (%rdi), %eax
24 ; CHECK-NEXT: andl $15, %eax
25 ; CHECK-NEXT: leaq (%rdi,%rax,4), %rax
28 %bf.load = load i8, i8* %data, align 4
29 %bf.clear = shl i8 %bf.load, 2
30 %0 = and i8 %bf.clear, 60
31 %mul = zext i8 %0 to i64
32 %add.ptr = getelementptr inbounds i8, i8* %data, i64 %mul
36 ; If the shift op is SHL, the logic op can only be AND.
37 define i64 @test3(i8* %data) {
39 ; CHECK: # %bb.0: # %entry
40 ; CHECK-NEXT: movb (%rdi), %al
41 ; CHECK-NEXT: shlb $2, %al
42 ; CHECK-NEXT: xorb $60, %al
43 ; CHECK-NEXT: movzbl %al, %eax
46 %bf.load = load i8, i8* %data, align 4
47 %bf.clear = shl i8 %bf.load, 2
48 %0 = xor i8 %bf.clear, 60
49 %mul = zext i8 %0 to i64
53 define i64 @test4(i8* %data) {
55 ; CHECK: # %bb.0: # %entry
56 ; CHECK-NEXT: movl (%rdi), %eax
57 ; CHECK-NEXT: shrq $2, %rax
58 ; CHECK-NEXT: andl $60, %eax
61 %bf.load = load i8, i8* %data, align 4
62 %bf.clear = lshr i8 %bf.load, 2
63 %0 = and i8 %bf.clear, 60
64 %1 = zext i8 %0 to i64
68 define i64 @test5(i8* %data) {
70 ; CHECK: # %bb.0: # %entry
71 ; CHECK-NEXT: movzbl (%rdi), %eax
72 ; CHECK-NEXT: shrq $2, %rax
73 ; CHECK-NEXT: xorq $60, %rax
76 %bf.load = load i8, i8* %data, align 4
77 %bf.clear = lshr i8 %bf.load, 2
78 %0 = xor i8 %bf.clear, 60
79 %1 = zext i8 %0 to i64
83 define i64 @test6(i8* %data) {
85 ; CHECK: # %bb.0: # %entry
86 ; CHECK-NEXT: movzbl (%rdi), %eax
87 ; CHECK-NEXT: shrq $2, %rax
88 ; CHECK-NEXT: orq $60, %rax
91 %bf.load = load i8, i8* %data, align 4
92 %bf.clear = lshr i8 %bf.load, 2
93 %0 = or i8 %bf.clear, 60
94 %1 = zext i8 %0 to i64
98 ; Load is folded with sext.
99 define i64 @test8(i8* %data) {
100 ; CHECK-LABEL: test8:
101 ; CHECK: # %bb.0: # %entry
102 ; CHECK-NEXT: movsbl (%rdi), %eax
103 ; CHECK-NEXT: movzwl %ax, %eax
104 ; CHECK-NEXT: shrl $2, %eax
105 ; CHECK-NEXT: orl $60, %eax
108 %bf.load = load i8, i8* %data, align 4
109 %ext = sext i8 %bf.load to i16
110 %bf.clear = lshr i16 %ext, 2
111 %0 = or i16 %bf.clear, 60
112 %1 = zext i16 %0 to i64