diff options
author | Craig Topper <craig.topper@intel.com> | 2018-10-28 01:32:49 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@intel.com> | 2018-10-28 01:32:49 +0000 |
commit | c4b785ae1ef3351c299e8d027f00c268d2d6e278 (patch) | |
tree | 07168bbde2b5615c4d08e790777f0b8ce2336c75 /llvm/lib/CodeGen/SelectionDAG | |
parent | f206447dcdcee87a244d31ff7c30887c4149c060 (diff) | |
download | bcm5719-llvm-c4b785ae1ef3351c299e8d027f00c268d2d6e278.tar.gz bcm5719-llvm-c4b785ae1ef3351c299e8d027f00c268d2d6e278.zip |
[DAGCombiner] Better constant vector support for FCOPYSIGN.
Enable constant folding when both operands are vectors of constants.
Turn into FNEG/FABS when the RHS is a splat constant vector.
llvm-svn: 345469
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 318e398211c..906223a624c 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -11590,15 +11590,15 @@ static inline bool CanCombineFCOPYSIGN_EXTEND_ROUND(SDNode *N) { SDValue DAGCombiner::visitFCOPYSIGN(SDNode *N) { SDValue N0 = N->getOperand(0); SDValue N1 = N->getOperand(1); - ConstantFPSDNode *N0CFP = dyn_cast<ConstantFPSDNode>(N0); - ConstantFPSDNode *N1CFP = dyn_cast<ConstantFPSDNode>(N1); + bool N0CFP = isConstantFPBuildVectorOrConstantFP(N0); + bool N1CFP = isConstantFPBuildVectorOrConstantFP(N1); EVT VT = N->getValueType(0); if (N0CFP && N1CFP) // Constant fold return DAG.getNode(ISD::FCOPYSIGN, SDLoc(N), VT, N0, N1); - if (N1CFP) { - const APFloat &V = N1CFP->getValueAPF(); + if (ConstantFPSDNode *N1C = isConstOrConstSplatFP(N->getOperand(1))) { + const APFloat &V = N1C->getValueAPF(); // copysign(x, c1) -> fabs(x) iff ispos(c1) // copysign(x, c1) -> fneg(fabs(x)) iff isneg(c1) if (!V.isNegative()) { |