|
66 | 66 | #include <bitset> |
67 | 67 | #include <cctype> |
68 | 68 | #include <numeric> |
69 | | -#include <queue> |
70 | 69 | using namespace llvm; |
71 | 70 |
|
72 | 71 | #define DEBUG_TYPE "x86-isel" |
@@ -53389,80 +53388,6 @@ static SDValue combineMaskedStore(SDNode *N, SelectionDAG &DAG, |
53389 | 53388 | return SDValue(); |
53390 | 53389 | } |
53391 | 53390 |
|
53392 | | -static SDValue foldToMaskedStore(StoreSDNode *Store, SelectionDAG &DAG, |
53393 | | - const SDLoc &Dl, |
53394 | | - const X86Subtarget &Subtarget) { |
53395 | | - if (!Subtarget.hasAVX() && !Subtarget.hasAVX2() && !Subtarget.hasAVX512()) |
53396 | | - return SDValue(); |
53397 | | - |
53398 | | - if (!Store->isSimple()) |
53399 | | - return SDValue(); |
53400 | | - |
53401 | | - SDValue StoredVal = Store->getValue(); |
53402 | | - SDValue StorePtr = Store->getBasePtr(); |
53403 | | - SDValue StoreOffset = Store->getOffset(); |
53404 | | - EVT VT = StoredVal.getValueType(); |
53405 | | - const TargetLowering &TLI = DAG.getTargetLoweringInfo(); |
53406 | | - |
53407 | | - if (!TLI.isTypeLegal(VT) || !TLI.isOperationLegalOrCustom(ISD::MSTORE, VT)) |
53408 | | - return SDValue(); |
53409 | | - |
53410 | | - if (StoredVal.getOpcode() != ISD::VSELECT) |
53411 | | - return SDValue(); |
53412 | | - |
53413 | | - SDValue Mask = StoredVal.getOperand(0); |
53414 | | - SDValue TrueVec = StoredVal.getOperand(1); |
53415 | | - SDValue FalseVec = StoredVal.getOperand(2); |
53416 | | - |
53417 | | - LoadSDNode *Load = cast<LoadSDNode>(FalseVec.getNode()); |
53418 | | - if (!Load || !Load->isSimple()) |
53419 | | - return SDValue(); |
53420 | | - |
53421 | | - SDValue LoadPtr = Load->getBasePtr(); |
53422 | | - SDValue LoadOffset = Load->getOffset(); |
53423 | | - |
53424 | | - if (StorePtr != LoadPtr || StoreOffset != LoadOffset) |
53425 | | - return SDValue(); |
53426 | | - |
53427 | | - auto IsSafeToFold = [](StoreSDNode *Store, LoadSDNode *Load) { |
53428 | | - std::queue<SDValue> Worklist; |
53429 | | - |
53430 | | - Worklist.push(Store->getChain()); |
53431 | | - |
53432 | | - while (!Worklist.empty()) { |
53433 | | - SDValue Chain = Worklist.front(); |
53434 | | - Worklist.pop(); |
53435 | | - |
53436 | | - SDNode *Node = Chain.getNode(); |
53437 | | - if (!Node) |
53438 | | - return false; |
53439 | | - |
53440 | | - if (const auto *MemNode = dyn_cast<MemSDNode>(Node)) |
53441 | | - if (!MemNode->isSimple() || MemNode->writeMem()) |
53442 | | - return false; |
53443 | | - |
53444 | | - if (Node == Load) |
53445 | | - return true; |
53446 | | - |
53447 | | - if (Node->getOpcode() == ISD::TokenFactor) { |
53448 | | - for (unsigned i = 0; i < Node->getNumOperands(); ++i) |
53449 | | - Worklist.push(Node->getOperand(i)); |
53450 | | - } else { |
53451 | | - Worklist.push(Node->getOperand(0)); |
53452 | | - } |
53453 | | - } |
53454 | | - |
53455 | | - return false; |
53456 | | - }; |
53457 | | - |
53458 | | - if (!IsSafeToFold(Store, Load)) |
53459 | | - return SDValue(); |
53460 | | - |
53461 | | - return DAG.getMaskedStore(Store->getChain(), Dl, TrueVec, StorePtr, |
53462 | | - StoreOffset, Mask, Store->getMemoryVT(), |
53463 | | - Store->getMemOperand(), Store->getAddressingMode()); |
53464 | | -} |
53465 | | - |
53466 | 53391 | static SDValue combineStore(SDNode *N, SelectionDAG &DAG, |
53467 | 53392 | TargetLowering::DAGCombinerInfo &DCI, |
53468 | 53393 | const X86Subtarget &Subtarget) { |
@@ -53788,9 +53713,6 @@ static SDValue combineStore(SDNode *N, SelectionDAG &DAG, |
53788 | 53713 | St->getMemOperand()->getFlags()); |
53789 | 53714 | } |
53790 | 53715 |
|
53791 | | - if (SDValue MaskedStore = foldToMaskedStore(St, DAG, dl, Subtarget)) |
53792 | | - return MaskedStore; |
53793 | | - |
53794 | 53716 | return SDValue(); |
53795 | 53717 | } |
53796 | 53718 |
|
|
0 commit comments