diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2019-06-24 15:20:49 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2019-06-24 15:20:49 +0000 |
| commit | 89efefb170e893ad7dfe90cf973485ae8dac1af8 (patch) | |
| tree | dcc37d4246f580b46a21660404f0c52c4fd9d19a /llvm/lib/Transforms | |
| parent | 5dbd9228c44716614f3ae2747fbd241be83382b6 (diff) | |
| download | bcm5719-llvm-89efefb170e893ad7dfe90cf973485ae8dac1af8.tar.gz bcm5719-llvm-89efefb170e893ad7dfe90cf973485ae8dac1af8.zip | |
[InstCombine] reduce funnel-shift i16 X, X, 8 to bswap X
Prefer the more exact intrinsic to remove a use of the input value
and possibly make further transforms easier (we will still need
to match patterns with funnel-shift of wider types as pieces of
bswap, especially if we want to canonicalize to funnel-shift with
constant shift amount). Discussed in D46760.
llvm-svn: 364187
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index 1b247245c4c..63f313e1f7f 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -1983,6 +1983,13 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) { if (match(Op0, m_ZeroInt()) || match(Op0, m_Undef())) return BinaryOperator::CreateLShr(Op1, ConstantExpr::getSub(WidthC, ShAmtC)); + + // fshl i16 X, X, 8 --> bswap i16 X (reduce to more-specific form) + if (Op0 == Op1 && BitWidth == 16 && match(ShAmtC, m_SpecificInt(8))) { + Module *Mod = II->getModule(); + Function *Bswap = Intrinsic::getDeclaration(Mod, Intrinsic::bswap, Ty); + return CallInst::Create(Bswap, { Op0 }); + } } // Left or right might be masked. |

