|
27 | 27 | #include "llvm/Analysis/BlockFrequencyInfo.h"
|
28 | 28 | #include "llvm/Analysis/ProfileSummaryInfo.h"
|
29 | 29 | #include "llvm/Analysis/VectorUtils.h"
|
| 30 | +#include "llvm/CodeGen/ISDOpcodes.h" |
30 | 31 | #include "llvm/CodeGen/IntrinsicLowering.h"
|
31 | 32 | #include "llvm/CodeGen/LivePhysRegs.h"
|
32 | 33 | #include "llvm/CodeGen/MachineFrameInfo.h"
|
@@ -35385,18 +35386,48 @@ bool X86TargetLowering::isNarrowingProfitable(SDNode *N, EVT SrcVT,
|
35385 | 35386 |
|
35386 | 35387 | bool X86TargetLowering::shouldFoldSelectWithIdentityConstant(unsigned Opcode,
|
35387 | 35388 | EVT VT) const {
|
| 35389 | + if (!VT.isVector()) { |
| 35390 | + if (!Subtarget.hasBMI() || (VT != MVT::i32 && VT != MVT::i64)) |
| 35391 | + return false; |
| 35392 | + if (Opcode != ISD::AND && Opcode != ISD::XOR) |
| 35393 | + return false; |
| 35394 | + return true; |
| 35395 | + } |
| 35396 | + |
35388 | 35397 | // TODO: This is too general. There are cases where pre-AVX512 codegen would
|
35389 | 35398 | // benefit. The transform may also be profitable for scalar code.
|
35390 | 35399 | if (!Subtarget.hasAVX512())
|
35391 | 35400 | return false;
|
35392 | 35401 | if (!Subtarget.hasVLX() && !VT.is512BitVector())
|
35393 | 35402 | return false;
|
35394 |
| - if (!VT.isVector() || VT.getScalarType() == MVT::i1) |
| 35403 | + if (VT.getScalarType() == MVT::i1) |
35395 | 35404 | return false;
|
35396 | 35405 |
|
35397 | 35406 | return true;
|
35398 | 35407 | }
|
35399 | 35408 |
|
| 35409 | +bool X86TargetLowering::shouldFoldSelectWithIdentityConstant( |
| 35410 | + unsigned BinOpcode, unsigned SelectOpcode, SDValue X, |
| 35411 | + SDValue NonIdConstNode) const { |
| 35412 | + using namespace llvm::SDPatternMatch; |
| 35413 | + |
| 35414 | + if (SelectOpcode == ISD::VSELECT) |
| 35415 | + return true; |
| 35416 | + // BLSI |
| 35417 | + if (BinOpcode == ISD::AND && sd_match(NonIdConstNode, m_Neg(m_Specific(X)))) |
| 35418 | + return true; |
| 35419 | + // BLSR |
| 35420 | + if (BinOpcode == ISD::AND && |
| 35421 | + sd_match(NonIdConstNode, m_Add(m_Specific(X), m_AllOnes()))) |
| 35422 | + return true; |
| 35423 | + // BLSMSK |
| 35424 | + if (BinOpcode == ISD::XOR && |
| 35425 | + sd_match(NonIdConstNode, m_Add(m_Specific(X), m_AllOnes()))) |
| 35426 | + return true; |
| 35427 | + |
| 35428 | + return false; |
| 35429 | +} |
| 35430 | + |
35400 | 35431 | /// Targets can use this to indicate that they only support *some*
|
35401 | 35432 | /// VECTOR_SHUFFLE operations, those with specific masks.
|
35402 | 35433 | /// By default, if a target supports the VECTOR_SHUFFLE node, all mask values
|
|
0 commit comments