Sanjay Patel | 91d1ed5 | 2016-12-02 17:48:48 +0000 | [diff] [blame] | 1 | ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
Sanjay Patel | a5dbdf3 | 2016-12-02 17:58:26 +0000 | [diff] [blame] | 2 | ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=-bmi | FileCheck %s --check-prefix=ALL --check-prefix=NO_BMI |
| 3 | ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+bmi | FileCheck %s --check-prefix=ALL --check-prefix=BMI |
Sanjay Patel | 91d1ed5 | 2016-12-02 17:48:48 +0000 | [diff] [blame] | 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) { |
Sanjay Patel | 1f158d6 | 2016-12-05 15:58:21 +0000 | [diff] [blame] | 8 | ; ALL-LABEL: shrink_xor_constant1: |
| 9 | ; ALL: # BB#0: |
| 10 | ; ALL-NEXT: shrl $31, %edi |
| 11 | ; ALL-NEXT: xorl $1, %edi |
| 12 | ; ALL-NEXT: movl %edi, %eax |
| 13 | ; ALL-NEXT: retq |
Sanjay Patel | 91d1ed5 | 2016-12-02 17:48:48 +0000 | [diff] [blame] | 14 | ; |
| 15 | %sh = lshr i32 %x, 31 |
| 16 | %not = xor i32 %sh, -1 |
| 17 | %and = and i32 %not, 1 |
| 18 | ret i32 %and |
| 19 | } |
| 20 | |
| 21 | ; Clear low bits via shift, set them with xor (not), then mask them off. |
| 22 | |
| 23 | define i8 @shrink_xor_constant2(i8 %x) { |
Sanjay Patel | a5dbdf3 | 2016-12-02 17:58:26 +0000 | [diff] [blame] | 24 | ; ALL-LABEL: shrink_xor_constant2: |
| 25 | ; ALL: # BB#0: |
| 26 | ; ALL-NEXT: shlb $5, %dil |
Sanjay Patel | 1f158d6 | 2016-12-05 15:58:21 +0000 | [diff] [blame] | 27 | ; ALL-NEXT: xorb $-32, %dil |
Sanjay Patel | a5dbdf3 | 2016-12-02 17:58:26 +0000 | [diff] [blame] | 28 | ; ALL-NEXT: movl %edi, %eax |
| 29 | ; ALL-NEXT: retq |
Sanjay Patel | 91d1ed5 | 2016-12-02 17:48:48 +0000 | [diff] [blame] | 30 | ; |
| 31 | %sh = shl i8 %x, 5 |
| 32 | %not = xor i8 %sh, -1 |
| 33 | %and = and i8 %not, 224 ; 0xE0 |
| 34 | ret i8 %and |
| 35 | } |
| 36 | |