diff options
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 17 | 
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 9c70b662c86..29adcad22e1 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -83,6 +83,7 @@ STATISTIC(PostIndexedNodes, "Number of post-indexed nodes created");  STATISTIC(OpsNarrowed     , "Number of load/op/store narrowed");  STATISTIC(LdStFP2Int      , "Number of fp load/store pairs transformed to int");  STATISTIC(SlicedLoads, "Number of load sliced"); +STATISTIC(NumFPLogicOpsConv, "Number of logic ops converted to fp ops");  static cl::opt<bool>  CombinerGlobalAA("combiner-global-alias-analysis", cl::Hidden, @@ -9843,19 +9844,29 @@ static SDValue foldBitcastedFPLogic(SDNode *N, SelectionDAG &DAG,      FPOpcode = ISD::FNEG;      SignMask = APInt::getSignMask(SourceVT.getScalarSizeInBits());      break; -  // TODO: ISD::OR --> ISD::FNABS? +  case ISD::OR: +    FPOpcode = ISD::FABS; +    SignMask = APInt::getSignMask(SourceVT.getScalarSizeInBits()); +    break;    default:      return SDValue();    }    // Fold (bitcast int (and (bitcast fp X to int), 0x7fff...) to fp) -> fabs X    // Fold (bitcast int (xor (bitcast fp X to int), 0x8000...) to fp) -> fneg X +  // Fold (bitcast int (or (bitcast fp X to int), 0x8000...) to fp) -> +  //   fneg (fabs X)    SDValue LogicOp0 = N0.getOperand(0);    ConstantSDNode *LogicOp1 = isConstOrConstSplat(N0.getOperand(1), true);    if (LogicOp1 && LogicOp1->getAPIntValue() == SignMask &&        LogicOp0.getOpcode() == ISD::BITCAST && -      LogicOp0.getOperand(0).getValueType() == VT) -    return DAG.getNode(FPOpcode, SDLoc(N), VT, LogicOp0.getOperand(0)); +      LogicOp0.getOperand(0).getValueType() == VT) { +    SDValue FPOp = DAG.getNode(FPOpcode, SDLoc(N), VT, LogicOp0.getOperand(0)); +    NumFPLogicOpsConv++; +    if (N0.getOpcode() == ISD::OR) +      return DAG.getNode(ISD::FNEG, SDLoc(N), VT, FPOp); +    return FPOp; +  }    return SDValue();  }  | 

