|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py |
| 2 | +; RUN: llc < %s -mtriple=i686-unknown-unknown | FileCheck %s --check-prefix=X86 |
| 3 | +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+cmov | FileCheck %s --check-prefix=X64 |
| 4 | + |
| 5 | +; |
| 6 | +; PR48768 - 'and' clears the overflow flag, so we don't need a separate 'test'. |
| 7 | +; |
| 8 | + |
| 9 | +define i8 @and_i8_ri(i8 %0, i8 %1) { |
| 10 | +; X86-LABEL: and_i8_ri: |
| 11 | +; X86: # %bb.0: |
| 12 | +; X86-NEXT: movb {{[0-9]+}}(%esp), %al |
| 13 | +; X86-NEXT: movl %eax, %ecx |
| 14 | +; X86-NEXT: andb $-17, %cl |
| 15 | +; X86-NEXT: je .LBB0_2 |
| 16 | +; X86-NEXT: # %bb.1: |
| 17 | +; X86-NEXT: movl %ecx, %eax |
| 18 | +; X86-NEXT: .LBB0_2: |
| 19 | +; X86-NEXT: retl |
| 20 | +; |
| 21 | +; X64-LABEL: and_i8_ri: |
| 22 | +; X64: # %bb.0: |
| 23 | +; X64-NEXT: movl %edi, %eax |
| 24 | +; X64-NEXT: andb $-17, %al |
| 25 | +; X64-NEXT: movzbl %al, %eax |
| 26 | +; X64-NEXT: cmovel %edi, %eax |
| 27 | +; X64-NEXT: # kill: def $al killed $al killed $eax |
| 28 | +; X64-NEXT: retq |
| 29 | + %3 = and i8 %0, -17 |
| 30 | + %4 = icmp eq i8 %3, 0 |
| 31 | + %5 = select i1 %4, i8 %0, i8 %3 |
| 32 | + ret i8 %5 |
| 33 | +} |
| 34 | + |
| 35 | +define i8 @and_i8_rr(i8 %0, i8 %1) { |
| 36 | +; X86-LABEL: and_i8_rr: |
| 37 | +; X86: # %bb.0: |
| 38 | +; X86-NEXT: movb {{[0-9]+}}(%esp), %al |
| 39 | +; X86-NEXT: movb {{[0-9]+}}(%esp), %cl |
| 40 | +; X86-NEXT: andb %al, %cl |
| 41 | +; X86-NEXT: je .LBB1_2 |
| 42 | +; X86-NEXT: # %bb.1: |
| 43 | +; X86-NEXT: movl %ecx, %eax |
| 44 | +; X86-NEXT: .LBB1_2: |
| 45 | +; X86-NEXT: retl |
| 46 | +; |
| 47 | +; X64-LABEL: and_i8_rr: |
| 48 | +; X64: # %bb.0: |
| 49 | +; X64-NEXT: movl %esi, %eax |
| 50 | +; X64-NEXT: andl %edi, %eax |
| 51 | +; X64-NEXT: testb %al, %al |
| 52 | +; X64-NEXT: cmovel %edi, %eax |
| 53 | +; X64-NEXT: # kill: def $al killed $al killed $eax |
| 54 | +; X64-NEXT: retq |
| 55 | + %3 = and i8 %1, %0 |
| 56 | + %4 = icmp eq i8 %3, 0 |
| 57 | + %5 = select i1 %4, i8 %0, i8 %3 |
| 58 | + ret i8 %5 |
| 59 | +} |
| 60 | + |
| 61 | +define i16 @and_i16_ri(i16 %0, i16 %1) { |
| 62 | +; X86-LABEL: and_i16_ri: |
| 63 | +; X86: # %bb.0: |
| 64 | +; X86-NEXT: movl {{[0-9]+}}(%esp), %eax |
| 65 | +; X86-NEXT: movl %eax, %ecx |
| 66 | +; X86-NEXT: andl $-17, %ecx |
| 67 | +; X86-NEXT: testw %cx, %cx |
| 68 | +; X86-NEXT: je .LBB2_2 |
| 69 | +; X86-NEXT: # %bb.1: |
| 70 | +; X86-NEXT: movl %ecx, %eax |
| 71 | +; X86-NEXT: .LBB2_2: |
| 72 | +; X86-NEXT: # kill: def $ax killed $ax killed $eax |
| 73 | +; X86-NEXT: retl |
| 74 | +; |
| 75 | +; X64-LABEL: and_i16_ri: |
| 76 | +; X64: # %bb.0: |
| 77 | +; X64-NEXT: movl %edi, %eax |
| 78 | +; X64-NEXT: andl $-17, %eax |
| 79 | +; X64-NEXT: testw %ax, %ax |
| 80 | +; X64-NEXT: cmovel %edi, %eax |
| 81 | +; X64-NEXT: # kill: def $ax killed $ax killed $eax |
| 82 | +; X64-NEXT: retq |
| 83 | + %3 = and i16 %0, -17 |
| 84 | + %4 = icmp eq i16 %3, 0 |
| 85 | + %5 = select i1 %4, i16 %0, i16 %3 |
| 86 | + ret i16 %5 |
| 87 | +} |
| 88 | + |
| 89 | +define i16 @and_i16_rr(i16 %0, i16 %1) { |
| 90 | +; X86-LABEL: and_i16_rr: |
| 91 | +; X86: # %bb.0: |
| 92 | +; X86-NEXT: movl {{[0-9]+}}(%esp), %eax |
| 93 | +; X86-NEXT: movzwl {{[0-9]+}}(%esp), %ecx |
| 94 | +; X86-NEXT: andw %ax, %cx |
| 95 | +; X86-NEXT: je .LBB3_2 |
| 96 | +; X86-NEXT: # %bb.1: |
| 97 | +; X86-NEXT: movl %ecx, %eax |
| 98 | +; X86-NEXT: .LBB3_2: |
| 99 | +; X86-NEXT: # kill: def $ax killed $ax killed $eax |
| 100 | +; X86-NEXT: retl |
| 101 | +; |
| 102 | +; X64-LABEL: and_i16_rr: |
| 103 | +; X64: # %bb.0: |
| 104 | +; X64-NEXT: movl %esi, %eax |
| 105 | +; X64-NEXT: andl %edi, %eax |
| 106 | +; X64-NEXT: testw %ax, %ax |
| 107 | +; X64-NEXT: cmovel %edi, %eax |
| 108 | +; X64-NEXT: # kill: def $ax killed $ax killed $eax |
| 109 | +; X64-NEXT: retq |
| 110 | + %3 = and i16 %1, %0 |
| 111 | + %4 = icmp eq i16 %3, 0 |
| 112 | + %5 = select i1 %4, i16 %0, i16 %3 |
| 113 | + ret i16 %5 |
| 114 | +} |
| 115 | + |
| 116 | +define i32 @and_i32_ri(i32 %0, i32 %1) { |
| 117 | +; X86-LABEL: and_i32_ri: |
| 118 | +; X86: # %bb.0: |
| 119 | +; X86-NEXT: movl {{[0-9]+}}(%esp), %eax |
| 120 | +; X86-NEXT: movl %eax, %ecx |
| 121 | +; X86-NEXT: andl $-17, %ecx |
| 122 | +; X86-NEXT: testl %ecx, %ecx |
| 123 | +; X86-NEXT: jle .LBB4_2 |
| 124 | +; X86-NEXT: # %bb.1: |
| 125 | +; X86-NEXT: movl %ecx, %eax |
| 126 | +; X86-NEXT: .LBB4_2: |
| 127 | +; X86-NEXT: retl |
| 128 | +; |
| 129 | +; X64-LABEL: and_i32_ri: |
| 130 | +; X64: # %bb.0: |
| 131 | +; X64-NEXT: movl %edi, %eax |
| 132 | +; X64-NEXT: andl $-17, %eax |
| 133 | +; X64-NEXT: testl %eax, %eax |
| 134 | +; X64-NEXT: cmovlel %edi, %eax |
| 135 | +; X64-NEXT: retq |
| 136 | + %3 = and i32 %0, -17 |
| 137 | + %4 = icmp slt i32 %3, 1 |
| 138 | + %5 = select i1 %4, i32 %0, i32 %3 |
| 139 | + ret i32 %5 |
| 140 | +} |
| 141 | + |
| 142 | +define i32 @and_i32_rr(i32 %0, i32 %1) { |
| 143 | +; X86-LABEL: and_i32_rr: |
| 144 | +; X86: # %bb.0: |
| 145 | +; X86-NEXT: movl {{[0-9]+}}(%esp), %eax |
| 146 | +; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx |
| 147 | +; X86-NEXT: andl %eax, %ecx |
| 148 | +; X86-NEXT: testl %ecx, %ecx |
| 149 | +; X86-NEXT: jle .LBB5_2 |
| 150 | +; X86-NEXT: # %bb.1: |
| 151 | +; X86-NEXT: movl %ecx, %eax |
| 152 | +; X86-NEXT: .LBB5_2: |
| 153 | +; X86-NEXT: retl |
| 154 | +; |
| 155 | +; X64-LABEL: and_i32_rr: |
| 156 | +; X64: # %bb.0: |
| 157 | +; X64-NEXT: movl %esi, %eax |
| 158 | +; X64-NEXT: andl %edi, %eax |
| 159 | +; X64-NEXT: testl %eax, %eax |
| 160 | +; X64-NEXT: cmovlel %edi, %eax |
| 161 | +; X64-NEXT: retq |
| 162 | + %3 = and i32 %1, %0 |
| 163 | + %4 = icmp slt i32 %3, 1 |
| 164 | + %5 = select i1 %4, i32 %0, i32 %3 |
| 165 | + ret i32 %5 |
| 166 | +} |
| 167 | + |
| 168 | +define i64 @and_i64_ri(i64 %0, i64 %1) nounwind { |
| 169 | +; X86-LABEL: and_i64_ri: |
| 170 | +; X86: # %bb.0: |
| 171 | +; X86-NEXT: pushl %esi |
| 172 | +; X86-NEXT: movl {{[0-9]+}}(%esp), %eax |
| 173 | +; X86-NEXT: movl {{[0-9]+}}(%esp), %edx |
| 174 | +; X86-NEXT: movl %eax, %ecx |
| 175 | +; X86-NEXT: andl $-17, %ecx |
| 176 | +; X86-NEXT: cmpl $1, %ecx |
| 177 | +; X86-NEXT: movl %edx, %esi |
| 178 | +; X86-NEXT: sbbl $0, %esi |
| 179 | +; X86-NEXT: jl .LBB6_2 |
| 180 | +; X86-NEXT: # %bb.1: |
| 181 | +; X86-NEXT: movl %ecx, %eax |
| 182 | +; X86-NEXT: .LBB6_2: |
| 183 | +; X86-NEXT: popl %esi |
| 184 | +; X86-NEXT: retl |
| 185 | +; |
| 186 | +; X64-LABEL: and_i64_ri: |
| 187 | +; X64: # %bb.0: |
| 188 | +; X64-NEXT: movq %rdi, %rax |
| 189 | +; X64-NEXT: andq $-17, %rax |
| 190 | +; X64-NEXT: testq %rax, %rax |
| 191 | +; X64-NEXT: cmovleq %rdi, %rax |
| 192 | +; X64-NEXT: retq |
| 193 | + %3 = and i64 %0, -17 |
| 194 | + %4 = icmp slt i64 %3, 1 |
| 195 | + %5 = select i1 %4, i64 %0, i64 %3 |
| 196 | + ret i64 %5 |
| 197 | +} |
| 198 | + |
| 199 | +define i64 @and_i64_rr(i64 %0, i64 %1) nounwind { |
| 200 | +; X86-LABEL: and_i64_rr: |
| 201 | +; X86: # %bb.0: |
| 202 | +; X86-NEXT: pushl %edi |
| 203 | +; X86-NEXT: pushl %esi |
| 204 | +; X86-NEXT: movl {{[0-9]+}}(%esp), %eax |
| 205 | +; X86-NEXT: movl {{[0-9]+}}(%esp), %edx |
| 206 | +; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx |
| 207 | +; X86-NEXT: andl %edx, %ecx |
| 208 | +; X86-NEXT: movl {{[0-9]+}}(%esp), %esi |
| 209 | +; X86-NEXT: andl %eax, %esi |
| 210 | +; X86-NEXT: cmpl $1, %esi |
| 211 | +; X86-NEXT: movl %ecx, %edi |
| 212 | +; X86-NEXT: sbbl $0, %edi |
| 213 | +; X86-NEXT: jl .LBB7_2 |
| 214 | +; X86-NEXT: # %bb.1: |
| 215 | +; X86-NEXT: movl %esi, %eax |
| 216 | +; X86-NEXT: movl %ecx, %edx |
| 217 | +; X86-NEXT: .LBB7_2: |
| 218 | +; X86-NEXT: popl %esi |
| 219 | +; X86-NEXT: popl %edi |
| 220 | +; X86-NEXT: retl |
| 221 | +; |
| 222 | +; X64-LABEL: and_i64_rr: |
| 223 | +; X64: # %bb.0: |
| 224 | +; X64-NEXT: movq %rsi, %rax |
| 225 | +; X64-NEXT: andq %rdi, %rax |
| 226 | +; X64-NEXT: testq %rax, %rax |
| 227 | +; X64-NEXT: cmovleq %rdi, %rax |
| 228 | +; X64-NEXT: retq |
| 229 | + %3 = and i64 %1, %0 |
| 230 | + %4 = icmp slt i64 %3, 1 |
| 231 | + %5 = select i1 %4, i64 %0, i64 %3 |
| 232 | + ret i64 %5 |
| 233 | +} |
0 commit comments