summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2019-05-21 14:47:38 +0000
committerSanjay Patel <spatel@rotateright.com>2019-05-21 14:47:38 +0000
commit78c3f58122f4edcf8e707b2fb8ab1c9ae2054b03 (patch)
tree003cffb04f509154db4fad38a9e7880bca809d6c /llvm/lib
parenta7b9e98fd8e230869e45fd8313291360a07aa0c9 (diff)
downloadbcm5719-llvm-78c3f58122f4edcf8e707b2fb8ab1c9ae2054b03.tar.gz
bcm5719-llvm-78c3f58122f4edcf8e707b2fb8ab1c9ae2054b03.zip
[DAGCombiner] prevent unsafe reassociation of FP ops
There are no FP callers of DAGCombiner::reassociateOps() currently, but we can add a fast-math check to make sure this API is not being misused. This was noted as a potential risk (and that risk might increase) with: D62191 llvm-svn: 361268
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 799f95274b2..0aa481ff2e2 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -1042,6 +1042,13 @@ SDValue DAGCombiner::reassociateOps(unsigned Opc, const SDLoc &DL, SDValue N0,
// Don't reassociate reductions.
if (Flags.hasVectorReduction())
return SDValue();
+
+ // Floating-point reassociation is not allowed without loose FP math.
+ if (N0.getValueType().isFloatingPoint() ||
+ N1.getValueType().isFloatingPoint())
+ if (!Flags.hasAllowReassociation() || !Flags.hasNoSignedZeros())
+ return SDValue();
+
if (SDValue Combined = reassociateOpsCommutative(Opc, DL, N0, N1))
return Combined;
if (SDValue Combined = reassociateOpsCommutative(Opc, DL, N1, N0))
@@ -1728,7 +1735,7 @@ SDValue DAGCombiner::combine(SDNode *N) {
}
}
- // If N is a commutative binary node, try eliminate it if the commuted
+ // If N is a commutative binary node, try to eliminate it if the commuted
// version is already present in the DAG.
if (!RV.getNode() && TLI.isCommutativeBinOp(N->getOpcode()) &&
N->getNumValues() == 1) {
OpenPOWER on IntegriCloud