blob: 3bee4472c1465dc42d3ff78b8f74eb0d6313ed32 [file] [log] [blame]
Sanjay Patel91d1ed52016-12-02 17:48:48 +00001; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
Sanjay Patela5dbdf32016-12-02 17:58:26 +00002; 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 Patel91d1ed52016-12-02 17:48:48 +00004
5; Clear high bits via shift, set them with xor (not), then mask them off.
6
7define 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
31define i8 @shrink_xor_constant2(i8 %x) {
Sanjay Patela5dbdf32016-12-02 17:58:26 +000032; ALL-LABEL: shrink_xor_constant2:
33; ALL: # BB#0:
34; ALL-NEXT: shlb $5, %dil
35; ALL-NEXT: notb %dil
36; ALL-NEXT: andb $-32, %dil
37; ALL-NEXT: movl %edi, %eax
38; ALL-NEXT: retq
Sanjay Patel91d1ed52016-12-02 17:48:48 +000039;
40 %sh = shl i8 %x, 5
41 %not = xor i8 %sh, -1
42 %and = and i8 %not, 224 ; 0xE0
43 ret i8 %and
44}
45