diff options
| author | Craig Topper <craig.topper@intel.com> | 2019-10-12 00:01:08 +0000 |
|---|---|---|
| committer | Craig Topper <craig.topper@intel.com> | 2019-10-12 00:01:08 +0000 |
| commit | 3472feb94cdf90ce8d4761b2c44f080da1b5a79d (patch) | |
| tree | 9b32fc1ac6bbefc2b2426c65b5e73fe085547639 /llvm/lib/Target | |
| parent | 7dcd440d44ddaf5c31f99128b1869e9dea5b767c (diff) | |
| download | bcm5719-llvm-3472feb94cdf90ce8d4761b2c44f080da1b5a79d.tar.gz bcm5719-llvm-3472feb94cdf90ce8d4761b2c44f080da1b5a79d.zip | |
[X86] Fold a VTRUNCS/VTRUNCUS+store into a saturating truncating store.
We already did this for VTRUNCUS with a specific combination of
types. This extends this to VTRUNCS and handles any types where
a truncating store is legal.
llvm-svn: 374615
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/X86/X86ISelLowering.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 38b6b96f3d7..81df19b827f 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -40332,11 +40332,11 @@ static SDValue combineStore(SDNode *N, SelectionDAG &DAG, TargetLowering::DAGCombinerInfo &DCI, const X86Subtarget &Subtarget) { StoreSDNode *St = cast<StoreSDNode>(N); - EVT VT = St->getValue().getValueType(); EVT StVT = St->getMemoryVT(); SDLoc dl(St); unsigned Alignment = St->getAlignment(); - SDValue StoredVal = St->getOperand(1); + SDValue StoredVal = St->getValue(); + EVT VT = StoredVal.getValueType(); const TargetLowering &TLI = DAG.getTargetLoweringInfo(); // Convert a store of vXi1 into a store of iX and a bitcast. @@ -40453,17 +40453,15 @@ static SDValue combineStore(SDNode *N, SelectionDAG &DAG, MVT::v16i8, St->getMemOperand()); } - // Try to fold a vpmovuswb 256->128 into a truncating store. - // FIXME: Generalize this to other types. - // FIXME: Do the same for signed saturation. - if (!St->isTruncatingStore() && VT == MVT::v16i8 && - St->getValue().getOpcode() == X86ISD::VTRUNCUS && - St->getValue().getOperand(0).getValueType() == MVT::v16i16 && - TLI.isTruncStoreLegal(MVT::v16i16, MVT::v16i8) && - St->getValue().hasOneUse()) { - return EmitTruncSStore(false /* Unsigned saturation */, St->getChain(), - dl, St->getValue().getOperand(0), St->getBasePtr(), - MVT::v16i8, St->getMemOperand(), DAG); + // Try to fold a VTRUNCUS or VTRUNCS into a truncating store. + if (!St->isTruncatingStore() && StoredVal.hasOneUse() && + (StoredVal.getOpcode() == X86ISD::VTRUNCUS || + StoredVal.getOpcode() == X86ISD::VTRUNCS) && + TLI.isTruncStoreLegal(StoredVal.getOperand(0).getValueType(), VT)) { + bool IsSigned = StoredVal.getOpcode() == X86ISD::VTRUNCS; + return EmitTruncSStore(IsSigned, St->getChain(), + dl, StoredVal.getOperand(0), St->getBasePtr(), + VT, St->getMemOperand(), DAG); } // Optimize trunc store (of multiple scalars) to shuffle and store. |

