1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s
4 ; Various tests for ands that should be implemented with movzx, but aren't due
5 ; demanded bits shortcomings.
7 ; The backend will insert a zext to promote the shift to i32.
8 define i16 @test1(i16 %x) {
11 ; CHECK-NEXT: movzwl %di, %eax
12 ; CHECK-NEXT: shrl %eax
13 ; CHECK-NEXT: # kill: def $ax killed $ax killed $eax
19 define i32 @test2(i32 %x) {
22 ; CHECK-NEXT: movzwl %di, %eax
23 ; CHECK-NEXT: shrl %eax
25 %y = and i32 %x, 65535
30 define i32 @test3(i32 %x) {
33 ; CHECK-NEXT: movzbl %dil, %eax
34 ; CHECK-NEXT: shrl %eax
41 define i16 @test4(i16 %x) {
44 ; CHECK-NEXT: movzbl %dil, %eax
45 ; CHECK-NEXT: shrl %eax
46 ; CHECK-NEXT: # kill: def $ax killed $ax killed $eax
53 define i16 @test5(i16 %x) {
56 ; CHECK-NEXT: movzwl %di, %eax
57 ; CHECK-NEXT: shrl $9, %eax
58 ; CHECK-NEXT: # kill: def $ax killed $ax killed $eax
64 define i32 @test6(i32 %x) {
67 ; CHECK-NEXT: movzwl %di, %eax
68 ; CHECK-NEXT: shrl $9, %eax
70 %y = and i32 %x, 65535
75 ; TODO: We could turn this and into a zero extend.
76 define i32 @test7(i32 %x) {
79 ; CHECK-NEXT: orl $1, %edi
80 ; CHECK-NEXT: movzwl %di, %eax
82 %y = and i32 %x, 65534
87 ; We actually get a movzx on this one, but only because we canonicalize the and
88 ; after the or before SimplifyDemandedBits messes it up.
89 define i32 @test8(i32 %x) {
92 ; CHECK-NEXT: orl $1, %edi
93 ; CHECK-NEXT: movzwl %di, %eax
95 %y = and i32 %x, 65535
100 define i64 @add_neg_one(i64 %x) {
101 ; CHECK-LABEL: add_neg_one:
103 ; CHECK-NEXT: leal -1(%rdi), %eax
104 ; CHECK-NEXT: andl %edi, %eax
105 ; CHECK-NEXT: movzwl %ax, %eax
107 %a1 = and i64 %x, 65535
108 %a2 = add i64 %x, 65535
109 %r = and i64 %a1, %a2
113 define i64 @sub_neg_one(i64 %x) {
114 ; CHECK-LABEL: sub_neg_one:
116 ; CHECK-NEXT: leal -65535(%rdi), %eax
117 ; CHECK-NEXT: andl %edi, %eax
118 ; CHECK-NEXT: movzwl %ax, %eax
120 %a1 = and i64 %x, 65535
121 %a2 = sub i64 %x, 65535
122 %r = and i64 %a1, %a2
126 define i64 @mul_neg_one(i64 %x) {
127 ; CHECK-LABEL: mul_neg_one:
129 ; CHECK-NEXT: movl %edi, %eax
130 ; CHECK-NEXT: negl %eax
131 ; CHECK-NEXT: andl %edi, %eax
132 ; CHECK-NEXT: movzwl %ax, %eax
134 %a1 = and i64 %x, 65535
135 %a2 = mul i64 %x, 65535
136 %r = and i64 %a1, %a2
140 define i32 @PR36689(ptr) {
141 ; CHECK-LABEL: PR36689:
143 ; CHECK-NEXT: movzwl (%rdi), %eax
144 ; CHECK-NEXT: orl $255, %eax
146 %2 = load i32, ptr %0
147 %3 = and i32 %2, 65280