diff options
| author | Bob Wilson <bob.wilson@apple.com> | 2010-07-29 20:34:14 +0000 | 
|---|---|---|
| committer | Bob Wilson <bob.wilson@apple.com> | 2010-07-29 20:34:14 +0000 | 
| commit | 728eb292eb27c540d7f0f78b4173a62b103c769a (patch) | |
| tree | 3bb54e2ac081980113aeec9c824d34f62b35b9ed /llvm/lib/Target | |
| parent | 2bff50546c6844ed7cc7160b81b1fc844ec1000c (diff) | |
| download | bcm5719-llvm-728eb292eb27c540d7f0f78b4173a62b103c769a.tar.gz bcm5719-llvm-728eb292eb27c540d7f0f78b4173a62b103c769a.zip | |
Refactor ARM-specific DAG combining in preparation for adding some more
transformations.
llvm-svn: 109800
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/ARM/ARMISelLowering.cpp | 37 | 
1 files changed, 25 insertions, 12 deletions
| diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp index 69b24d0c7a6..571dc2e63e9 100644 --- a/llvm/lib/Target/ARM/ARMISelLowering.cpp +++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp @@ -4221,30 +4221,43 @@ SDValue combineSelectAndUse(SDNode *N, SDValue Slct, SDValue OtherOp,    return SDValue();  } -/// PerformADDCombine - Target-specific dag combine xforms for ISD::ADD. -static SDValue PerformADDCombine(SDNode *N, -                                 TargetLowering::DAGCombinerInfo &DCI) { -  // added by evan in r37685 with no testcase. -  SDValue N0 = N->getOperand(0), N1 = N->getOperand(1); - +/// PerformADDCombineWithOperands - Try DAG combinations for an ADD with +/// operands N0 and N1.  This is a helper for PerformADDCombine that is +/// called with the default operands, and if that fails, with commuted +/// operands. +static SDValue PerformADDCombineWithOperands(SDNode *N, SDValue N0, SDValue N1, +                                         TargetLowering::DAGCombinerInfo &DCI) {    // fold (add (select cc, 0, c), x) -> (select cc, x, (add, x, c))    if (N0.getOpcode() == ISD::SELECT && N0.getNode()->hasOneUse()) {      SDValue Result = combineSelectAndUse(N, N0, N1, DCI);      if (Result.getNode()) return Result;    } -  if (N1.getOpcode() == ISD::SELECT && N1.getNode()->hasOneUse()) { -    SDValue Result = combineSelectAndUse(N, N1, N0, DCI); -    if (Result.getNode()) return Result; -  }    return SDValue();  } +/// PerformADDCombine - Target-specific dag combine xforms for ISD::ADD. +/// +static SDValue PerformADDCombine(SDNode *N, +                                 TargetLowering::DAGCombinerInfo &DCI) { +  SDValue N0 = N->getOperand(0); +  SDValue N1 = N->getOperand(1); + +  // First try with the default operand order. +  SDValue Result = PerformADDCombineWithOperands(N, N0, N1, DCI); +  if (Result.getNode()) +    return Result; + +  // If that didn't work, try again with the operands commuted. +  return PerformADDCombineWithOperands(N, N1, N0, DCI); +} +  /// PerformSUBCombine - Target-specific dag combine xforms for ISD::SUB. +///  static SDValue PerformSUBCombine(SDNode *N,                                   TargetLowering::DAGCombinerInfo &DCI) { -  // added by evan in r37685 with no testcase. -  SDValue N0 = N->getOperand(0), N1 = N->getOperand(1); +  SDValue N0 = N->getOperand(0); +  SDValue N1 = N->getOperand(1);    // fold (sub x, (select cc, 0, c)) -> (select cc, x, (sub, x, c))    if (N1.getOpcode() == ISD::SELECT && N1.getNode()->hasOneUse()) { | 

