From 7772de25d07c977e41f8faa3bbf327033cd81c20 Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Mon, 21 May 2018 21:41:02 +0000 Subject: [DAGCombine][X86][AArch64] Masked merge unfolding: vector edition. Summary: This **appears** to be the last missing piece for the masked merge pattern handling in the backend. This is [[ https://bugs.llvm.org/show_bug.cgi?id=37104 | PR37104 ]]. [[ https://bugs.llvm.org/show_bug.cgi?id=6773 | PR6773 ]] will introduce an IR canonicalization that is likely bad for the end assembly. Previously, `andps`+`andnps` / `bsl` would be generated. (see `@out`) Now, they would no longer be generated (see `@in`), and we need to make sure that they are generated. Differential Revision: https://reviews.llvm.org/D46528 llvm-svn: 332904 --- llvm/lib/Target/X86/X86ISelLowering.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'llvm/lib/Target/X86/X86ISelLowering.cpp') diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 594dbed93fe..cfb4074300e 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -4751,26 +4751,39 @@ bool X86TargetLowering::isMaskAndCmp0FoldingBeneficial( } bool X86TargetLowering::hasAndNotCompare(SDValue Y) const { - // A mask and compare against constant is ok for an 'andn' too - // even though the BMI instruction doesn't have an immediate form. + EVT VT = Y.getValueType(); + + if (VT.isVector()) + return false; if (!Subtarget.hasBMI()) return false; // There are only 32-bit and 64-bit forms for 'andn'. - EVT VT = Y.getValueType(); if (VT != MVT::i32 && VT != MVT::i64) return false; + // A mask and compare against constant is ok for an 'andn' too + // even though the BMI instruction doesn't have an immediate form. + return true; } bool X86TargetLowering::hasAndNot(SDValue Y) const { - // x86 can't form 'andn' with an immediate. - if (isa(Y)) + EVT VT = Y.getValueType(); + + if (!VT.isVector()) // x86 can't form 'andn' with an immediate. + return !isa(Y) && hasAndNotCompare(Y); + + // Vector. + + if (!Subtarget.hasSSE1() || VT.getSizeInBits() < 128) return false; - return hasAndNotCompare(Y); + if (VT == MVT::v4i32) + return true; + + return Subtarget.hasSSE2(); } MVT X86TargetLowering::hasFastEqualityCompare(unsigned NumBits) const { -- cgit v1.2.3