[PATCH] D145142: [X86] Add test for `~x & x` -> `0` in DAG Lowering; NFC

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 1 23:43:33 PST 2023


goldstein.w.n created this revision.
Herald added a subscriber: pengfei.
Herald added a project: All.
goldstein.w.n requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145142

Files:
  llvm/test/CodeGen/X86/andn-x-x.ll


Index: llvm/test/CodeGen/X86/andn-x-x.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/X86/andn-x-x.ll
@@ -0,0 +1,46 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-pc-linux-gnu | FileCheck %s
+
+define <2 x i64> @andnp_xx(<2 x i64> %v0) nounwind {
+; CHECK-LABEL: andnp_xx:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    andnps %xmm0, %xmm0
+; CHECK-NEXT:    retq
+  %x = xor <2 x i64> %v0, <i64 -1, i64 -1>
+  %y = and <2 x i64> %v0, %x
+  ret <2 x i64> %y
+}
+
+define <2 x i64> @andnp_xx_2(<2 x i64> %v0) nounwind {
+; CHECK-LABEL: andnp_xx_2:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    andnps %xmm0, %xmm0
+; CHECK-NEXT:    retq
+  %x = xor <2 x i64> %v0, <i64 -1, i64 -1>
+  %y = and <2 x i64> %x, %v0
+  ret <2 x i64> %y
+}
+
+define i64 @andn_xx(i64 %v0) nounwind {
+; CHECK-LABEL: andn_xx:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    movq %rdi, %rax
+; CHECK-NEXT:    notq %rax
+; CHECK-NEXT:    andq %rdi, %rax
+; CHECK-NEXT:    retq
+  %x = xor i64 %v0, -1
+  %y = and i64 %v0, %x
+  ret i64 %y
+}
+
+define i64 @andn_xx_2(i64 %v0) nounwind {
+; CHECK-LABEL: andn_xx_2:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    movq %rdi, %rax
+; CHECK-NEXT:    notq %rax
+; CHECK-NEXT:    andq %rdi, %rax
+; CHECK-NEXT:    retq
+  %x = xor i64 %v0, -1
+  %y = and i64 %x, %v0
+  ret i64 %y
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145142.501762.patch
Type: text/x-patch
Size: 1410 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230302/5a6fe00a/attachment.bin>


More information about the llvm-commits mailing list