summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2016-12-02 17:48:48 +0000
committerSanjay Patel <spatel@rotateright.com>2016-12-02 17:48:48 +0000
commit91d1ed5ee6061fd49e36d6c2a20146ec160fed62 (patch)
treece96075044c1c5dddc6e06de63a0e46bcc52a9e4 /llvm/test/CodeGen
parent2df9963fe3a9558198a79c323cc873df8e1abb53 (diff)
downloadbcm5719-llvm-91d1ed5ee6061fd49e36d6c2a20146ec160fed62.tar.gz
bcm5719-llvm-91d1ed5ee6061fd49e36d6c2a20146ec160fed62.zip
[x86] add tests to show missing demanded bits analysis; NFC
llvm-svn: 288515
Diffstat (limited to 'llvm/test/CodeGen')
-rw-r--r--llvm/test/CodeGen/X86/not-and-simplify.ll53
1 files changed, 53 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/not-and-simplify.ll b/llvm/test/CodeGen/X86/not-and-simplify.ll
new file mode 100644
index 00000000000..23d8cdec748
--- /dev/null
+++ b/llvm/test/CodeGen/X86/not-and-simplify.ll
@@ -0,0 +1,53 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=-bmi | FileCheck %s --check-prefix=NO_BMI
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+bmi | FileCheck %s --check-prefix=BMI
+
+; Clear high bits via shift, set them with xor (not), then mask them off.
+
+define i32 @shrink_xor_constant1(i32 %x) {
+; NO_BMI-LABEL: shrink_xor_constant1:
+; NO_BMI: # BB#0:
+; NO_BMI-NEXT: shrl $31, %edi
+; NO_BMI-NEXT: notl %edi
+; NO_BMI-NEXT: andl $1, %edi
+; NO_BMI-NEXT: movl %edi, %eax
+; NO_BMI-NEXT: retq
+;
+; BMI-LABEL: shrink_xor_constant1:
+; BMI: # BB#0:
+; BMI-NEXT: shrl $31, %edi
+; BMI-NEXT: movl $1, %eax
+; BMI-NEXT: andnl %eax, %edi, %eax
+; BMI-NEXT: retq
+;
+ %sh = lshr i32 %x, 31
+ %not = xor i32 %sh, -1
+ %and = and i32 %not, 1
+ ret i32 %and
+}
+
+; Clear low bits via shift, set them with xor (not), then mask them off.
+
+define i8 @shrink_xor_constant2(i8 %x) {
+; NO_BMI-LABEL: shrink_xor_constant2:
+; NO_BMI: # BB#0:
+; NO_BMI-NEXT: shlb $5, %dil
+; NO_BMI-NEXT: notb %dil
+; NO_BMI-NEXT: andb $-32, %dil
+; NO_BMI-NEXT: movl %edi, %eax
+; NO_BMI-NEXT: retq
+;
+; BMI-LABEL: shrink_xor_constant3:
+; BMI: # BB#0:
+; BMI-NEXT: shlb $5, %dil
+; BMI-NEXT: notb %dil
+; BMI-NEXT: andb $-32, %dil
+; BMI-NEXT: movl %edi, %eax
+; BMI-NEXT: retq
+;
+ %sh = shl i8 %x, 5
+ %not = xor i8 %sh, -1
+ %and = and i8 %not, 224 ; 0xE0
+ ret i8 %and
+}
+
OpenPOWER on IntegriCloud