diff options
author | Sanjay Patel <spatel@rotateright.com> | 2018-07-29 16:36:38 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2018-07-29 16:36:38 +0000 |
commit | 54421ce91801f2a57524f664e6d4f9c65482c983 (patch) | |
tree | 12d4a8dcf032aff4fd71c5afa37f5731a4a4a827 /llvm/lib | |
parent | 46af5835af5708c35c3e242aa6c9ae5eee81806f (diff) | |
download | bcm5719-llvm-54421ce91801f2a57524f664e6d4f9c65482c983.tar.gz bcm5719-llvm-54421ce91801f2a57524f664e6d4f9c65482c983.zip |
[InstSimplify] fold funnel shifts with 0-shift amount
llvm-svn: 338218
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Analysis/InstructionSimplify.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index c75bc93c3fb..607ec382074 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -4775,6 +4775,19 @@ static Value *simplifyIntrinsic(Function *F, IterTy ArgBegin, IterTy ArgEnd, return PassthruArg; return nullptr; } + case Intrinsic::fshl: + case Intrinsic::fshr: { + Value *ShAmtArg = ArgBegin[2]; + const APInt *ShAmtC; + if (match(ShAmtArg, m_APInt(ShAmtC))) { + // If there's effectively no shift, return the 1st arg or 2nd arg. + // TODO: For vectors, we could check each element of a non-splat constant. + APInt BitWidth = APInt(ShAmtC->getBitWidth(), ShAmtC->getBitWidth()); + if (ShAmtC->urem(BitWidth).isNullValue()) + return ArgBegin[IID == Intrinsic::fshl ? 0 : 1]; + } + return nullptr; + } default: return nullptr; } |