diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2018-12-13 12:23:32 +0000 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2018-12-13 12:23:32 +0000 |
commit | ab973a45b9796500955202ca606cf0bed083109b (patch) | |
tree | 4baba8d1f76529cf764a83e3a2160c9c50844668 /llvm/lib/CodeGen | |
parent | 1a4e2cc27a6cade6bf851edd93856f5a8c8482f0 (diff) | |
download | bcm5719-llvm-ab973a45b9796500955202ca606cf0bed083109b.tar.gz bcm5719-llvm-ab973a45b9796500955202ca606cf0bed083109b.zip |
[DAGCombine] Moved X86 rotate_amount % bitwidth == 0 early out to DAGCombiner
Remove common code from custom lowering (code is still safe if somehow a zero value gets used).
llvm-svn: 349028
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index d6defa5dc0b..7768d12c75c 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -6314,6 +6314,13 @@ SDValue DAGCombiner::visitRotate(SDNode *N) { if (isNullOrNullSplat(N1)) return N0; + // fold (rot x, c) -> x iff (c % BitSize) == 0 + if (isPowerOf2_32(Bitsize) && Bitsize > 1) { + APInt ModuloMask(N1.getScalarValueSizeInBits(), Bitsize - 1); + if (DAG.MaskedValueIsZero(N1, ModuloMask)) + return N0; + } + // fold (rot x, c) -> (rot x, c % BitSize) if (ConstantSDNode *Cst = isConstOrConstSplat(N1)) { if (Cst->getAPIntValue().uge(Bitsize)) { |