Sanjay Patel | 91d1ed5 | 2016-12-02 17:48:48 +0000 | [diff] [blame^] | 1 | ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
| 2 | ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=-bmi | FileCheck %s --check-prefix=NO_BMI |
| 3 | ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+bmi | FileCheck %s --check-prefix=BMI |
| 4 | |
| 5 | ; Clear high bits via shift, set them with xor (not), then mask them off. |
| 6 | |
| 7 | define i32 @shrink_xor_constant1(i32 %x) { |
| 8 | ; NO_BMI-LABEL: shrink_xor_constant1: |
| 9 | ; NO_BMI: # BB#0: |
| 10 | ; NO_BMI-NEXT: shrl $31, %edi |
| 11 | ; NO_BMI-NEXT: notl %edi |
| 12 | ; NO_BMI-NEXT: andl $1, %edi |
| 13 | ; NO_BMI-NEXT: movl %edi, %eax |
| 14 | ; NO_BMI-NEXT: retq |
| 15 | ; |
| 16 | ; BMI-LABEL: shrink_xor_constant1: |
| 17 | ; BMI: # BB#0: |
| 18 | ; BMI-NEXT: shrl $31, %edi |
| 19 | ; BMI-NEXT: movl $1, %eax |
| 20 | ; BMI-NEXT: andnl %eax, %edi, %eax |
| 21 | ; BMI-NEXT: retq |
| 22 | ; |
| 23 | %sh = lshr i32 %x, 31 |
| 24 | %not = xor i32 %sh, -1 |
| 25 | %and = and i32 %not, 1 |
| 26 | ret i32 %and |
| 27 | } |
| 28 | |
| 29 | ; Clear low bits via shift, set them with xor (not), then mask them off. |
| 30 | |
| 31 | define i8 @shrink_xor_constant2(i8 %x) { |
| 32 | ; NO_BMI-LABEL: shrink_xor_constant2: |
| 33 | ; NO_BMI: # BB#0: |
| 34 | ; NO_BMI-NEXT: shlb $5, %dil |
| 35 | ; NO_BMI-NEXT: notb %dil |
| 36 | ; NO_BMI-NEXT: andb $-32, %dil |
| 37 | ; NO_BMI-NEXT: movl %edi, %eax |
| 38 | ; NO_BMI-NEXT: retq |
| 39 | ; |
| 40 | ; BMI-LABEL: shrink_xor_constant3: |
| 41 | ; BMI: # BB#0: |
| 42 | ; BMI-NEXT: shlb $5, %dil |
| 43 | ; BMI-NEXT: notb %dil |
| 44 | ; BMI-NEXT: andb $-32, %dil |
| 45 | ; BMI-NEXT: movl %edi, %eax |
| 46 | ; BMI-NEXT: retq |
| 47 | ; |
| 48 | %sh = shl i8 %x, 5 |
| 49 | %not = xor i8 %sh, -1 |
| 50 | %and = and i8 %not, 224 ; 0xE0 |
| 51 | ret i8 %and |
| 52 | } |
| 53 | |