diff options
author | Sanjay Patel <spatel@rotateright.com> | 2018-11-20 17:34:59 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2018-11-20 17:34:59 +0000 |
commit | 14ab9170b8026b24a7d88bbab33e6e4494d55fa7 (patch) | |
tree | 6ce3fc66aeb6087ef22c98530fe3003711a9e323 /llvm/lib/Analysis | |
parent | 2778f56a40dba2efd6da9466a1405b4a097fb0b5 (diff) | |
download | bcm5719-llvm-14ab9170b8026b24a7d88bbab33e6e4494d55fa7.tar.gz bcm5719-llvm-14ab9170b8026b24a7d88bbab33e6e4494d55fa7.zip |
[InstSimplify] fold funnel shifts with undef operands
Splitting these off from the D54666.
Patch by: nikic (Nikita Popov)
llvm-svn: 347332
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/InstructionSimplify.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 599a2f2ce4c..9fc10af9668 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -5042,7 +5042,16 @@ static Value *simplifyIntrinsic(Function *F, IterTy ArgBegin, IterTy ArgEnd, } case Intrinsic::fshl: case Intrinsic::fshr: { - Value *ShAmtArg = ArgBegin[2]; + Value *Op0 = ArgBegin[0], *Op1 = ArgBegin[1], *ShAmtArg = ArgBegin[2]; + + // If both operands are undef, the result is undef. + if (match(Op0, m_Undef()) && match(Op1, m_Undef())) + return UndefValue::get(F->getReturnType()); + + // If shift amount is undef, assume it is zero. + if (match(ShAmtArg, m_Undef())) + return ArgBegin[IID == Intrinsic::fshl ? 0 : 1]; + const APInt *ShAmtC; if (match(ShAmtArg, m_APInt(ShAmtC))) { // If there's effectively no shift, return the 1st arg or 2nd arg. |