diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2019-05-08 22:19:52 +0000 | 
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2019-05-08 22:19:52 +0000 | 
| commit | 902b3ecdad8999519eb7436f72b533701ac168fa (patch) | |
| tree | 4e22a83075c4aae24881078245eab018c96afc85 /llvm/lib | |
| parent | f3fb7fac3232a661ed914f796eb029cc5ce2e3e4 (diff) | |
| download | bcm5719-llvm-902b3ecdad8999519eb7436f72b533701ac168fa.tar.gz bcm5719-llvm-902b3ecdad8999519eb7436f72b533701ac168fa.zip | |
[SelectionDAG] fold 'fneg undef' to undef
This is extracted from the original draft of D61419 with some additional tests.
We don't currently get this in IR (it's conservatively turned into a NaN),
but presumably that'll get updated as we add real IR support for 'fneg'
rather than 'fsub -0.0, x'.
The x86-32 run shows the following, and I haven't looked further to see why,
but that seems to be independent:
  Legalizing: t1: f32 = undef
  Trying to expand node
  Creating fp constant: t4: f32 = ConstantFP<0.000000e+00>
Differential Revision: https://reviews.llvm.org/D61516
llvm-svn: 360296
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 4 | 
1 files changed, 4 insertions, 0 deletions
| diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 3b14e00efab..3597c6d86c5 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -4482,6 +4482,10 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,        return Operand.getOperand(0);      break;    case ISD::FNEG: +    // Negation of an unknown bag of bits is still completely undefined. +    if (OpOpcode == ISD::UNDEF) +      return getUNDEF(VT); +      // -(X-Y) -> (Y-X) is unsafe because when X==Y, -0.0 != +0.0      if ((getTarget().Options.UnsafeFPMath || Flags.hasNoSignedZeros()) &&          OpOpcode == ISD::FSUB) | 

