summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2019-03-11 15:01:31 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2019-03-11 15:01:31 +0000
commit53518b45a577d80b38bcaa30d951932f5ddb62f6 (patch)
treed16d1c1e489f2d65eab530f7e708d7950c80e722
parent075e133a3d9a86e2b82c783f784541784f0c9de4 (diff)
downloadbcm5719-llvm-53518b45a577d80b38bcaa30d951932f5ddb62f6.tar.gz
bcm5719-llvm-53518b45a577d80b38bcaa30d951932f5ddb62f6.zip
[DAG] TargetLowering::SimplifySetCC - call FoldSetCC early to handle constant/commute folds.
Noticed while looking at PR40800 (and also D57921) llvm-svn: 355828
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp19
1 files changed, 6 insertions, 13 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index c4b46dd9f3d..093e35b86cb 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -2353,14 +2353,9 @@ SDValue TargetLowering::SimplifySetCC(EVT VT, SDValue N0, SDValue N1,
SelectionDAG &DAG = DCI.DAG;
EVT OpVT = N0.getValueType();
- // These setcc operations always fold.
- switch (Cond) {
- default: break;
- case ISD::SETFALSE:
- case ISD::SETFALSE2: return DAG.getBoolConstant(false, dl, VT, OpVT);
- case ISD::SETTRUE:
- case ISD::SETTRUE2: return DAG.getBoolConstant(true, dl, VT, OpVT);
- }
+ // Constant fold or commute setcc.
+ if (SDValue Fold = DAG.FoldSetCC(VT, N0, N1, Cond, dl))
+ return Fold;
// Ensure that the constant occurs on the RHS and fold constant comparisons.
// TODO: Handle non-splat vector constants. All undef causes trouble.
@@ -2947,11 +2942,9 @@ SDValue TargetLowering::SimplifySetCC(EVT VT, SDValue N0, SDValue N1,
}
}
- if (isa<ConstantFPSDNode>(N0.getNode())) {
- // Constant fold or commute setcc.
- SDValue O = DAG.FoldSetCC(VT, N0, N1, Cond, dl);
- if (O.getNode()) return O;
- } else if (auto *CFP = dyn_cast<ConstantFPSDNode>(N1.getNode())) {
+ if (!isa<ConstantFPSDNode>(N0) && isa<ConstantFPSDNode>(N1)) {
+ auto *CFP = cast<ConstantFPSDNode>(N1);
+
// If the RHS of an FP comparison is a constant, simplify it away in
// some cases.
if (CFP->getValueAPF().isNaN()) {
OpenPOWER on IntegriCloud