diff options
| author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2014-07-09 19:12:07 +0000 |
|---|---|---|
| committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2014-07-09 19:12:07 +0000 |
| commit | 658c5576d1395a6135ff5ab0541e241ac4d12d2d (patch) | |
| tree | 106b91ccb0b9afbf5a2840cca153c94a21f83a46 /llvm/lib/CodeGen | |
| parent | c0b1eae6b450770721cad022bff016557532e581 (diff) | |
| download | bcm5719-llvm-658c5576d1395a6135ff5ab0541e241ac4d12d2d.tar.gz bcm5719-llvm-658c5576d1395a6135ff5ab0541e241ac4d12d2d.zip | |
Add trunc (select c, a, b) -> select c (trunc a), (trunc b) combine.
Do this if the truncate is free and the select is legal.
llvm-svn: 212640
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 7497feb1e66..ab07954a6f1 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -6013,6 +6013,20 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) { } } + // trunc (select c, a, b) -> select c, (trunc a), (trunc b) + if (N0.getOpcode() == ISD::SELECT) { + EVT SrcVT = N0.getValueType(); + if ((!LegalOperations || TLI.isOperationLegal(ISD::SELECT, SrcVT)) && + TLI.isTruncateFree(SrcVT, VT)) { + SDLoc SL(N0); + SDValue TruncOp0 = DAG.getNode(ISD::TRUNCATE, SL, VT, N0.getOperand(1)); + SDValue TruncOp1 = DAG.getNode(ISD::TRUNCATE, SL, VT, N0.getOperand(2)); + EVT SetCCVT = getSetCCResultType(VT); + SDValue Cond = DAG.getSExtOrTrunc(N0.getOperand(0), SL, SetCCVT); + return DAG.getNode(ISD::SELECT, SDLoc(N), VT, Cond, TruncOp0, TruncOp1); + } + } + // Fold a series of buildvector, bitcast, and truncate if possible. // For example fold // (2xi32 trunc (bitcast ((4xi32)buildvector x, x, y, y) 2xi64)) to |

