diff options
author | Hans Wennborg <hans@hanshq.net> | 2017-12-04 20:39:57 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2017-12-04 20:39:57 +0000 |
commit | 7e61f249629d3d3d5f5c117f35d914cd3694b963 (patch) | |
tree | 0156ba288e54be69bfad3831eae1d750f8017d52 /llvm/lib/CodeGen | |
parent | 04e4f47e93e2bc26a80bf738c3692846ca622230 (diff) | |
download | bcm5719-llvm-7e61f249629d3d3d5f5c117f35d914cd3694b963.tar.gz bcm5719-llvm-7e61f249629d3d3d5f5c117f35d914cd3694b963.zip |
DAG: Match truncated rotation (PR35487)
If the truncation has been pushed past the or-node, look through it and
truncate afterwards.
Differential revision: https://reviews.llvm.org/D40792
llvm-svn: 319692
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 5387a7ed73e..30195ff4e91 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -4652,6 +4652,15 @@ SDNode *DAGCombiner::MatchRotate(SDValue LHS, SDValue RHS, const SDLoc &DL) { bool HasROTR = TLI.isOperationLegalOrCustom(ISD::ROTR, VT); if (!HasROTL && !HasROTR) return nullptr; + // Check for truncated rotate. + if (LHS.getOpcode() == ISD::TRUNCATE && RHS.getOpcode() == ISD::TRUNCATE) { + assert(LHS.getValueType() == RHS.getValueType()); + if (SDNode *Rot = MatchRotate(LHS.getOperand(0), RHS.getOperand(0), DL)) { + return DAG.getNode(ISD::TRUNCATE, SDLoc(LHS), LHS.getValueType(), + SDValue(Rot, 0)).getNode(); + } + } + // Match "(X shl/srl V1) & V2" where V2 may not be present. SDValue LHSShift; // The shift. SDValue LHSMask; // AND value if any. |