summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorQuentin Colombet <qcolombet@apple.com>2014-02-21 23:42:41 +0000
committerQuentin Colombet <qcolombet@apple.com>2014-02-21 23:42:41 +0000
commit0206b30ea6ca3cdd04d968ca676ccb025ef75158 (patch)
tree23ef37e7ee095f63edc3588bac4958e2385a0327 /test
parent94f20bfe6e9de6a1c80c7bfe2dc77202c88847b4 (diff)
downloadllvm-0206b30ea6ca3cdd04d968ca676ccb025ef75158.tar.gz
llvm-0206b30ea6ca3cdd04d968ca676ccb025ef75158.tar.bz2
llvm-0206b30ea6ca3cdd04d968ca676ccb025ef75158.tar.xz
[DAGCombiner] PCMP* sets its result to all ones or zeros so we can AND with the
shifted mask rather than masking and shifting separately. The patch adds this transformation to the DAGCombiner:   (shl (and (setcc:i8v16 ...) N01C) N1C) -> (and (setcc:i8v16 ...) N01C<<N1C) <rdar://problem/16054492> Patch by Adam Nemet <anemet@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201906 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/CodeGen/X86/shift-pcmp.ll30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/CodeGen/X86/shift-pcmp.ll b/test/CodeGen/X86/shift-pcmp.ll
new file mode 100644
index 0000000000..b15fb10dc1
--- /dev/null
+++ b/test/CodeGen/X86/shift-pcmp.ll
@@ -0,0 +1,30 @@
+; RUN: llc < %s -o - -mcpu=generic -march=x86-64 -mattr=+sse2 | FileCheck %s
+; RUN: llc < %s -o - -mcpu=generic -march=x86-64 -mattr=+avx | FileCheck %s
+
+define <8 x i16> @foo(<8 x i16> %a, <8 x i16> %b) {
+; CHECK: .short 32
+; CHECK-NEXT: .short 32
+; CHECK-NEXT: .short 32
+; CHECK-NEXT: .short 32
+; CHECK-NEXT: .short 32
+; CHECK-NEXT: .short 32
+; CHECK-NEXT: .short 32
+; CHECK-NEXT: .short 32
+; CHECK-LABEL: foo
+; CHECK-NOT: psll
+entry:
+ %icmp = icmp eq <8 x i16> %a, %b
+ %zext = zext <8 x i1> %icmp to <8 x i16>
+ %shl = shl nuw nsw <8 x i16> %zext, <i16 5, i16 5, i16 5, i16 5, i16 5, i16 5, i16 5, i16 5>
+ ret <8 x i16> %shl
+}
+
+; Don't fail with an assert due to an undef in the buildvector
+define <8 x i16> @bar(<8 x i16> %a, <8 x i16> %b) {
+; CHECK-LABEL: bar
+entry:
+ %icmp = icmp eq <8 x i16> %a, %b
+ %zext = zext <8 x i1> %icmp to <8 x i16>
+ %shl = shl nuw nsw <8 x i16> %zext, <i16 5, i16 undef, i16 5, i16 5, i16 5, i16 5, i16 5, i16 5>
+ ret <8 x i16> %shl
+}