diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2019-01-14 14:16:24 +0000 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2019-01-14 14:16:24 +0000 |
commit | 7fc6882374f805ed780f07001e317c8b0dc7711a (patch) | |
tree | 1e4d79d8bc29594a5796263f5808eaa8d65c3806 /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | |
parent | 7a99727c62ac457ad122aa6ede3500b75184426c (diff) | |
download | bcm5719-llvm-7fc6882374f805ed780f07001e317c8b0dc7711a.tar.gz bcm5719-llvm-7fc6882374f805ed780f07001e317c8b0dc7711a.zip |
[DAGCombiner] Add add/sub saturation undef handling
Match ConstantFolding.cpp:
(add_sat x, undef) -> -1
(sub_sat x, undef) -> 0
llvm-svn: 351070
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 9a40774cff8..25f2fc66b73 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -2194,6 +2194,10 @@ SDValue DAGCombiner::visitADDSAT(SDNode *N) { return N1; } + // fold (add_sat x, undef) -> -1 + if (N0.isUndef() || N1.isUndef()) + return DAG.getAllOnesConstant(DL, VT); + if (DAG.isConstantIntBuildVectorOrConstantInt(N0)) { // canonicalize constant to RHS if (!DAG.isConstantIntBuildVectorOrConstantInt(N1)) @@ -2792,6 +2796,10 @@ SDValue DAGCombiner::visitSUBSAT(SDNode *N) { return N0; } + // fold (sub_sat x, undef) -> 0 + if (N0.isUndef() || N1.isUndef()) + return DAG.getConstant(0, DL, VT); + // TODO Constant Folding // fold (sub_sat x, 0) -> x |