diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2016-08-23 17:30:56 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2016-08-23 17:30:56 +0000 |
| commit | 200e3cbfb0196f78e0901de4b19d63a1e80ae8d1 (patch) | |
| tree | 220c73c784bc1063a78d6dc97b4d31d294367dc5 /llvm/lib | |
| parent | 1972e222ea3b5f60fec026143a3bb29d8165cd7f (diff) | |
| download | bcm5719-llvm-200e3cbfb0196f78e0901de4b19d63a1e80ae8d1.tar.gz bcm5719-llvm-200e3cbfb0196f78e0901de4b19d63a1e80ae8d1.zip | |
[InstSimplify] allow icmp with constant folds for splat vectors, part 1
llvm-svn: 279538
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Analysis/InstructionSimplify.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 5b7805869ea..c048f3132ea 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -2154,17 +2154,21 @@ computePointerICmp(const DataLayout &DL, const TargetLibraryInfo *TLI, static Value *simplifyICmpWithConstant(CmpInst::Predicate Pred, Value *LHS, Value *RHS) { - // FIXME: Use m_APInt here and below to allow splat vector folds. - ConstantInt *CI = dyn_cast<ConstantInt>(RHS); - if (!CI) + const APInt *C; + if (!match(RHS, m_APInt(C))) return nullptr; // Rule out tautological comparisons (eg., ult 0 or uge 0). - ConstantRange RHS_CR = ICmpInst::makeConstantRange(Pred, CI->getValue()); + ConstantRange RHS_CR = ICmpInst::makeConstantRange(Pred, *C); if (RHS_CR.isEmptySet()) - return ConstantInt::getFalse(CI->getContext()); + return ConstantInt::getFalse(GetCompareTy(RHS)); if (RHS_CR.isFullSet()) - return ConstantInt::getTrue(CI->getContext()); + return ConstantInt::getTrue(GetCompareTy(RHS)); + + // FIXME: Use m_APInt below here to allow splat vector folds. + ConstantInt *CI = dyn_cast<ConstantInt>(RHS); + if (!CI) + return nullptr; // Many binary operators with constant RHS have easy to compute constant // range. Use them to check whether the comparison is a tautology. |

