diff options
| author | Craig Topper <craig.topper@intel.com> | 2019-04-09 18:33:56 +0000 | 
|---|---|---|
| committer | Craig Topper <craig.topper@intel.com> | 2019-04-09 18:33:56 +0000 | 
| commit | 61e77b11d1bf0fa02cfce416c56e6a598619d8db (patch) | |
| tree | 85b8aad010dddc9a20b8d04c79994877ac617054 /llvm/lib/CodeGen/SelectionDAG | |
| parent | 2f5e9de8d1f80e1e94e5eaacde7ba59ba0c55ca0 (diff) | |
| download | bcm5719-llvm-61e77b11d1bf0fa02cfce416c56e6a598619d8db.tar.gz bcm5719-llvm-61e77b11d1bf0fa02cfce416c56e6a598619d8db.zip | |
[DAGCombiner][X86][SystemZ] Canonicalize SSUBO with immediate RHS to SADDO by negating the immediate.
This lines up with what we do for regular subtract and it matches up better with X86 assumptions in isel patterns that add with immediate is more canonical than sub with immediate.
Differential Revision: https://reviews.llvm.org/D60020
llvm-svn: 358027
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 8 | 
1 files changed, 8 insertions, 0 deletions
| diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 5d7890ee08f..c61b24f8d21 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -3037,6 +3037,14 @@ SDValue DAGCombiner::visitSUBO(SDNode *N) {      return CombineTo(N, DAG.getConstant(0, DL, VT),                       DAG.getConstant(0, DL, CarryVT)); +  ConstantSDNode *N1C = getAsNonOpaqueConstant(N1); + +  // fold (subox, c) -> (addo x, -c) +  if (IsSigned && N1C && !N1C->getAPIntValue().isMinSignedValue()) { +    return DAG.getNode(ISD::SADDO, DL, N->getVTList(), N0, +                       DAG.getConstant(-N1C->getAPIntValue(), DL, VT)); +  } +    // fold (subo x, 0) -> x + no borrow    if (isNullOrNullSplat(N1))      return CombineTo(N, N0, DAG.getConstant(0, DL, CarryVT)); | 

